diff --git a/python/cudf_polars/cudf_polars/utils/cuda_stream.py b/python/cudf_polars/cudf_polars/utils/cuda_stream.py index a42252157b4..c0708d3bea8 100644 --- a/python/cudf_polars/cudf_polars/utils/cuda_stream.py +++ b/python/cudf_polars/cudf_polars/utils/cuda_stream.py @@ -13,6 +13,7 @@ if TYPE_CHECKING: from collections.abc import Callable, Sequence + from pylibcudf.utils import CudaStreamLike from rmm.pylibrmm.stream import Stream @@ -27,7 +28,7 @@ def get_cuda_stream() -> Stream: def join_cuda_streams( - *, downstreams: Sequence[Stream], upstreams: Sequence[Stream] + *, downstreams: Sequence[CudaStreamLike], upstreams: Sequence[CudaStreamLike] ) -> None: """ Join multiple CUDA streams. @@ -46,7 +47,7 @@ def join_cuda_streams( def get_joined_cuda_stream( - get_cuda_stream: Callable[[], Stream], *, upstreams: Sequence[Stream] + get_cuda_stream: Callable[[], Stream], *, upstreams: Sequence[CudaStreamLike] ) -> Stream: """ Return a CUDA stream that is joined to the given streams. diff --git a/python/pylibcudf/pylibcudf/binaryop.pxd b/python/pylibcudf/pylibcudf/binaryop.pxd index 29c9f3d98ea..a34a02b2191 100644 --- a/python/pylibcudf/pylibcudf/binaryop.pxd +++ b/python/pylibcudf/pylibcudf/binaryop.pxd @@ -1,10 +1,9 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp cimport bool from pylibcudf.libcudf.binaryop cimport binary_operator from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream from .column cimport Column from .scalar cimport Scalar @@ -25,7 +24,7 @@ cpdef Column binary_operation( RightBinaryOperand rhs, binary_operator op, DataType output_type, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) diff --git a/python/pylibcudf/pylibcudf/binaryop.pyi b/python/pylibcudf/pylibcudf/binaryop.pyi index 52263440db3..1f3c9a2cb64 100644 --- a/python/pylibcudf/pylibcudf/binaryop.pyi +++ b/python/pylibcudf/pylibcudf/binaryop.pyi @@ -1,14 +1,14 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from enum import IntEnum from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar from pylibcudf.types import DataType +from pylibcudf.utils import CudaStreamLike class BinaryOperator(IntEnum): ADD = ... @@ -52,7 +52,7 @@ def binary_operation( rhs: Column | Scalar, op: BinaryOperator, output_type: DataType, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def is_supported_operation( diff --git a/python/pylibcudf/pylibcudf/binaryop.pyx b/python/pylibcudf/pylibcudf/binaryop.pyx index a46b6aaaa81..20a69d60727 100644 --- a/python/pylibcudf/pylibcudf/binaryop.pyx +++ b/python/pylibcudf/pylibcudf/binaryop.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from cython.operator import dereference @@ -20,6 +20,7 @@ from .column cimport Column from .scalar cimport Scalar from .types cimport DataType from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["BinaryOperator", "binary_operation", "is_supported_operation"] @@ -28,7 +29,7 @@ cpdef Column binary_operation( RightBinaryOperand rhs, binary_operator op, DataType output_type, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Perform a binary operation between a column and another column or scalar. @@ -61,7 +62,8 @@ cpdef Column binary_operation( The result of the binary operation """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if LeftBinaryOperand is Column and RightBinaryOperand is Column: @@ -71,7 +73,7 @@ cpdef Column binary_operation( rhs.view(), op, output_type.c_obj, - stream.view(), + _cs, mr.get_mr() ) elif LeftBinaryOperand is Column and RightBinaryOperand is Scalar: @@ -81,7 +83,7 @@ cpdef Column binary_operation( dereference(rhs.c_obj), op, output_type.c_obj, - stream.view(), + _cs, mr.get_mr() ) elif LeftBinaryOperand is Scalar and RightBinaryOperand is Column: @@ -91,13 +93,13 @@ cpdef Column binary_operation( rhs.view(), op, output_type.c_obj, - stream.view(), + _cs, mr.get_mr() ) else: raise ValueError(f"Invalid arguments {lhs} and {rhs}") - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef bool is_supported_operation( diff --git a/python/pylibcudf/pylibcudf/column.pxd b/python/pylibcudf/pylibcudf/column.pxd index 7348d68f6de..429f85f39b0 100644 --- a/python/pylibcudf/pylibcudf/column.pxd +++ b/python/pylibcudf/pylibcudf/column.pxd @@ -6,7 +6,6 @@ from libcpp.vector cimport vector from libc.stdint cimport uint64_t from rmm.librmm.device_buffer cimport device_buffer -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport ( @@ -27,7 +26,7 @@ cdef class OwnerWithCAI: cdef dict cai @staticmethod - cdef create(column_view cv, object owner, Stream stream) + cdef create(column_view cv, object owner, object stream) cdef class OwnerMaskWithCAI: @@ -38,7 +37,7 @@ cdef class OwnerMaskWithCAI: cdef create(column_view cv, object owner) -cdef gpumemoryview _copy_array_to_device(object buf, Stream stream=*) +cdef gpumemoryview _copy_array_to_device(object buf, object stream=*) cdef class Column: @@ -61,7 +60,7 @@ cdef class Column: @staticmethod cdef Column from_libcudf( unique_ptr[column] libcudf_col, - Stream stream, + object stream, DeviceMemoryResource mr ) @@ -72,7 +71,7 @@ cdef class Column: cdef Column from_column_view_of_arbitrary( const column_view& cv, object owner, - Stream stream, + object stream, ) @staticmethod @@ -81,10 +80,10 @@ cdef class Column: tuple shape, DataType dtype, Column base=*, - Stream stream=*, + object stream=*, ) - cpdef Scalar to_scalar(self, Stream stream=*, DeviceMemoryResource mr=*) + cpdef Scalar to_scalar(self, object stream=*, DeviceMemoryResource mr=*) cpdef DataType type(self) cpdef Column child(self, size_type index) cpdef size_type num_children(self) @@ -95,7 +94,7 @@ cdef class Column: cpdef object data(self) cpdef object null_mask(self) cpdef list children(self) - cpdef Column copy(self, Stream stream=*, DeviceMemoryResource mr=*) + cpdef Column copy(self, object stream=*, DeviceMemoryResource mr=*) cpdef uint64_t device_buffer_size(self) cpdef Column with_mask(self, object, size_type, bint validate=*) @@ -108,10 +107,10 @@ cdef class ListsColumnView: cpdef child(self) cpdef offsets(self) cdef lists_column_view view(self) nogil - cpdef Column get_sliced_child(self, Stream stream=*) + cpdef Column get_sliced_child(self, object stream=*) cdef class StructsColumnView: cdef Column _column cdef structs_column_view view(self) nogil - cpdef Column get_sliced_child(self, int index, Stream stream=*) + cpdef Column get_sliced_child(self, int index, object stream=*) diff --git a/python/pylibcudf/pylibcudf/column.pyi b/python/pylibcudf/pylibcudf/column.pyi index 3ac4641ac13..3ff7f53f356 100644 --- a/python/pylibcudf/pylibcudf/column.pyi +++ b/python/pylibcudf/pylibcudf/column.pyi @@ -6,12 +6,12 @@ from typing import Any, Protocol, TypedDict from rmm.pylibrmm.device_buffer import DeviceBuffer from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf._interop_helpers import ArrowLike, ColumnMetadata from pylibcudf.scalar import Scalar from pylibcudf.span import Span from pylibcudf.types import DataType +from pylibcudf.utils import CudaStreamLike class ArrayInterfaceBase(TypedDict): shape: tuple[int, ...] @@ -64,7 +64,7 @@ class Column: def num_children(self) -> int: ... def copy( self, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def device_buffer_size(self) -> int: ... @@ -77,19 +77,19 @@ class Column: def from_scalar( scalar: Scalar, size: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def to_scalar( self, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Scalar: ... @staticmethod def all_null_like( like: Column, size: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... @staticmethod @@ -99,32 +99,34 @@ class Column: def to_arrow( self, metadata: ColumnMetadata | str | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, ) -> ArrowLike: ... # Private methods below are included because polars is currently using them, # but we want to remove stubs for these private methods eventually def _to_schema(self, metadata: Any = None) -> Any: ... - def _to_host_array(self, stream: Stream) -> Any: ... + def _to_host_array(self, stream: CudaStreamLike) -> Any: ... @staticmethod def from_arrow( obj: ArrowLike, dtype: DataType | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... @classmethod def from_cuda_array_interface( - cls, obj: SupportsCudaArrayInterface, stream: Stream | None = None + cls, + obj: SupportsCudaArrayInterface, + stream: CudaStreamLike | None = None, ) -> Column: ... @classmethod def from_array_interface( - cls, obj: SupportsArrayInterface, stream: Stream | None = None + cls, obj: SupportsArrayInterface, stream: CudaStreamLike | None = None ) -> Column: ... @classmethod def from_array( cls, obj: SupportsCudaArrayInterface | SupportsArrayInterface, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, ) -> Column: ... @staticmethod def struct_from_children(children: Sequence[Column]) -> Column: ... @@ -132,21 +134,23 @@ class Column: def from_iterable_of_py( obj: Iterable, dtype: DataType | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, ) -> Column: ... class ListsColumnView: def __init__(self, column: Column): ... def child(self) -> Column: ... def offsets(self) -> Column: ... - def get_sliced_child(self, stream: Stream | None = None) -> Column: ... + def get_sliced_child( + self, stream: CudaStreamLike | None = None + ) -> Column: ... class StructsColumnView: def __init__(self, column: Column): ... def child(self) -> Column: ... def offsets(self) -> Column: ... def get_sliced_child( - self, index: int, stream: Stream | None = None + self, index: int, stream: CudaStreamLike | None = None ) -> Column: ... def is_c_contiguous( diff --git a/python/pylibcudf/pylibcudf/column.pyx b/python/pylibcudf/pylibcudf/column.pyx index 96137f96256..fc8745dae26 100644 --- a/python/pylibcudf/pylibcudf/column.pyx +++ b/python/pylibcudf/pylibcudf/column.pyx @@ -67,6 +67,7 @@ from itertools import accumulate import functools import operator from typing import Iterable +from cuda.bindings.cyruntime cimport cudaStream_t try: import pyarrow as pa @@ -96,7 +97,7 @@ cdef class _ArrowColumnHolder: cdef class OwnerWithCAI: """An interface for column view's data with gpumemoryview via CAI.""" @staticmethod - cdef create(column_view cv, object owner, Stream stream): + cdef create(column_view cv, object owner, object stream): obj = OwnerWithCAI() obj.owner = owner # The default size of 0 will be applied for any type that stores data in the @@ -108,7 +109,7 @@ cdef class OwnerWithCAI: # Cast to Python integers before multiplying to avoid overflow. size = int(cv.size()) * int(cpp_size_of(cv.type())) elif cv.type().id() == type_id.STRING: - size = strings_column_view(cv).chars_size(stream.view()) + size = strings_column_view(cv).chars_size((stream).view().value()) obj.cai = { "shape": (size,), @@ -156,7 +157,7 @@ class ArrayInterfaceWrapper: self.__array_interface__ = iface -cdef gpumemoryview _copy_array_to_device(object buf, Stream stream=None): +cdef gpumemoryview _copy_array_to_device(object buf, object stream=None): """ Copy a host-side array.array buffer to device memory. @@ -175,11 +176,11 @@ cdef gpumemoryview _copy_array_to_device(object buf, Stream stream=None): cdef memoryview mv = memoryview(buf) cdef uintptr_t ptr = mv.obj.buffer_info()[0] cdef size_t nbytes = len(mv) * mv.itemsize - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) return gpumemoryview(DeviceBuffer.to_device( ptr, - stream + _stream )) @@ -401,7 +402,7 @@ cdef class Column: def from_arrow( obj: ArrowLike, dtype: DataType | None = None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ) -> ArrowLike: """ @@ -453,7 +454,8 @@ cdef class Column: cdef _ArrowColumnHolder result cdef unique_ptr[arrow_column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if hasattr(obj, "__arrow_c_device_array__"): @@ -469,7 +471,7 @@ cdef class Column: c_result = make_unique[arrow_column]( move(dereference(c_schema)), move(dereference(c_device_array)), - stream.view(), + _cs, result.mr.get_mr(), ) result.col.swap(c_result) @@ -477,7 +479,7 @@ cdef class Column: return Column.from_column_view_of_arbitrary( result.col.get().view(), result, - stream, + _stream, ) elif hasattr(obj, "__arrow_c_array__"): schema, h_array = obj.__arrow_c_array__() @@ -490,7 +492,7 @@ cdef class Column: c_result = make_unique[arrow_column]( move(dereference(c_schema)), move(dereference(c_array)), - stream.view(), + _cs, result.mr.get_mr(), ) result.col.swap(c_result) @@ -498,7 +500,7 @@ cdef class Column: return Column.from_column_view_of_arbitrary( result.col.get().view(), result, - stream, + _stream, ) elif hasattr(obj, "__arrow_c_stream__"): arrow_stream = obj.__arrow_c_stream__() @@ -514,7 +516,7 @@ cdef class Column: with nogil: c_result = make_unique[arrow_column]( move(dereference(c_arrow_stream)), - stream.view(), + _cs, result.mr.get_mr(), ) result.col.swap(c_result) @@ -522,7 +524,7 @@ cdef class Column: return Column.from_column_view_of_arbitrary( result.col.get().view(), result, - stream, + _stream, ) elif hasattr(obj, "__arrow_c_device_stream__"): # TODO: When we add support for this case, it should be moved above @@ -656,7 +658,7 @@ cdef class Column: @staticmethod cdef Column from_libcudf( unique_ptr[column] libcudf_col, - Stream stream, + object stream, DeviceMemoryResource mr ): """Create a Column from a libcudf column. @@ -667,6 +669,7 @@ cdef class Column: """ assert stream is not None, "stream cannot be None" assert mr is not None, "mr cannot be None" + cdef Stream _stream = stream cdef DataType dtype = DataType.from_libcudf(libcudf_col.get().type()) cdef size_type size = libcudf_col.get().size() @@ -677,13 +680,13 @@ cdef class Column: # Note that when converting to cudf Column objects we'll need to pull # out the base object. cdef gpumemoryview data = gpumemoryview( - DeviceBuffer.c_from_unique_ptr(move(contents.data), stream, mr) + DeviceBuffer.c_from_unique_ptr(move(contents.data), _stream, mr) ) cdef gpumemoryview mask = None if null_count > 0: mask = gpumemoryview( - DeviceBuffer.c_from_unique_ptr(move(contents.null_mask), stream, mr) + DeviceBuffer.c_from_unique_ptr(move(contents.null_mask), _stream, mr) ) children = [] @@ -772,7 +775,7 @@ cdef class Column: cdef Column from_column_view_of_arbitrary( const column_view& cv, object owner, - Stream stream, + object stream, ): """Create a Column from a libcudf column_view into an arbitrary owner. @@ -818,7 +821,7 @@ cdef class Column: def from_scalar( Scalar slr, size_type size, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Create a Column from a Scalar. @@ -839,18 +842,19 @@ cdef class Column: """ cdef const scalar* c_scalar = slr.get() cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = make_column_from_scalar( dereference(c_scalar), size, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) - cpdef Scalar to_scalar(self, Stream stream=None, DeviceMemoryResource mr=None): + cpdef Scalar to_scalar(self, object stream=None, DeviceMemoryResource mr=None): """ Return the first value of 1-element column as a Scalar. @@ -873,11 +877,12 @@ cdef class Column: cdef column_view cv = self.view() cdef unique_ptr[scalar] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - result = get_element(cv, 0, stream.view(), mr.get_mr()) + result = get_element(cv, 0, _cs, mr.get_mr()) return Scalar.from_libcudf(move(result)) @@ -885,7 +890,7 @@ cdef class Column: def all_null_like( Column like, size_type size, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Create an all null column from a template. @@ -904,18 +909,19 @@ cdef class Column: Column An all-null column of `size` rows and type matching `like`. """ - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) - cdef Scalar slr = Scalar.empty_like(like, stream, mr) + cdef Scalar slr = Scalar.empty_like(like, _stream, mr) cdef unique_ptr[column] c_result with nogil: c_result = make_column_from_scalar( dereference(slr.get()), size, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) @staticmethod cdef Column _wrap_nested_list_column( @@ -923,7 +929,7 @@ cdef class Column: tuple shape, DataType dtype, Column base=None, - Stream stream=None, + object stream=None, ): """ Construct a list Column from a gpumemoryview and array @@ -937,7 +943,7 @@ cdef class Column: """ ndim = len(shape) flat_size = functools.reduce(operator.mul, shape) - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) if base is None: base = Column( @@ -958,9 +964,9 @@ cdef class Column: offsets_col = sequence( outer_len + 1, - Scalar.from_py(0, int32_dtype, stream=stream), - Scalar.from_py(shape[i], int32_dtype, stream=stream), - stream, + Scalar.from_py(0, int32_dtype, stream=_stream), + Scalar.from_py(shape[i], int32_dtype, stream=_stream), + _stream, ) nested = Column( @@ -976,7 +982,7 @@ cdef class Column: return nested @classmethod - def from_array_interface(cls, obj, Stream stream=None): + def from_array_interface(cls, obj, object stream=None): """ Create a Column from an object implementing the NumPy Array Interface. @@ -1016,21 +1022,21 @@ cdef class Column: cdef const unsigned char* ptr cdef const unsigned char[:] view - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) if nbytes > 0: ptr = data_ptr view = ( ptr)[:nbytes] - dbuf = DeviceBuffer.to_device(view, stream) + dbuf = DeviceBuffer.to_device(view, _stream) else: - dbuf = DeviceBuffer(size=0, stream=stream) + dbuf = DeviceBuffer(size=0, stream=_stream) return Column._wrap_nested_list_column( - gpumemoryview(dbuf), shape, dtype, None, stream + gpumemoryview(dbuf), shape, dtype, None, _stream ) @classmethod - def from_cuda_array_interface(cls, obj, Stream stream=None): + def from_cuda_array_interface(cls, obj, object stream=None): """ Create a Column from an object implementing the CUDA Array Interface. @@ -1069,7 +1075,7 @@ cdef class Column: ) @classmethod - def from_array(cls, obj, Stream stream=None): + def from_array(cls, obj, object stream=None): """ Create a Column from any object which supports the NumPy or CUDA array interface. @@ -1115,7 +1121,7 @@ cdef class Column: def from_iterable_of_py( obj: Iterable, dtype: DataType | None = None, - Stream stream=None + object stream=None ) -> Column: """ Create a Column from a Python iterable of scalar values or nested iterables. @@ -1364,14 +1370,15 @@ cdef class Column: """The children of the column.""" return self._children - cpdef Column copy(self, Stream stream=None, DeviceMemoryResource mr=None): + cpdef Column copy(self, object stream=None, DeviceMemoryResource mr=None): """Create a copy of the column.""" cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = make_unique[column](self.view(), stream.view(), mr.get_mr()) - return Column.from_libcudf(move(c_result), stream, mr) + c_result = make_unique[column](self.view(), _cs, mr.get_mr()) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef uint64_t device_buffer_size(self): """ @@ -1419,10 +1426,12 @@ cdef class Column: return PyCapsule_New(raw_schema_ptr, 'arrow_schema', _release_schema) - def _to_host_array(self, Stream stream): + def _to_host_array(self, object stream): cdef ArrowArray* raw_host_array_ptr + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() with nogil: - raw_host_array_ptr = to_arrow_host_raw(self.view(), stream.view()) + raw_host_array_ptr = to_arrow_host_raw(self.view(), _cs) return PyCapsule_New(raw_host_array_ptr, "arrow_array", _release_array) @@ -1484,7 +1493,7 @@ cdef class ListsColumnView: """ return lists_column_view(self._column.view()) - cpdef Column get_sliced_child(self, Stream stream=None): + cpdef Column get_sliced_child(self, object stream=None): """ Get the list elements child properly sliced to match parent's view. @@ -1498,9 +1507,9 @@ cdef class ListsColumnView: Column The sliced elements column """ - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) - cdef column_view c_child = self.view().get_sliced_child(stream.view()) + cdef column_view c_child = self.view().get_sliced_child(_stream.view().value()) return Column.from_column_view(c_child, self._column.child(1)) @@ -1522,7 +1531,7 @@ cdef class StructsColumnView: """ return structs_column_view(self._column.view()) - cpdef Column get_sliced_child(self, int index, Stream stream=None): + cpdef Column get_sliced_child(self, int index, object stream=None): """ Get the struct elements child properly sliced to match parent's view. @@ -1538,9 +1547,10 @@ cdef class StructsColumnView: Column The sliced elements column """ - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) - cdef column_view c_child = self.view().get_sliced_child(index, stream.view()) + cdef cudaStream_t _cs = _stream.view().value() + cdef column_view c_child = self.view().get_sliced_child(index, _cs) return Column.from_column_view(c_child, self._column.child(index)) diff --git a/python/pylibcudf/pylibcudf/column_factories.pxd b/python/pylibcudf/pylibcudf/column_factories.pxd index d26b3396e30..3f9841c045d 100644 --- a/python/pylibcudf/pylibcudf/column_factories.pxd +++ b/python/pylibcudf/pylibcudf/column_factories.pxd @@ -2,7 +2,6 @@ # SPDX-License-Identifier: Apache-2.0 from pylibcudf.libcudf.types cimport mask_state from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream from .column cimport Column from .types cimport DataType, size_type, type_id @@ -20,7 +19,7 @@ cpdef Column make_numeric_column( DataType type_, size_type size, MaskArg mask, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -28,7 +27,7 @@ cpdef Column make_fixed_point_column( DataType type_, size_type size, MaskArg mask, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -36,7 +35,7 @@ cpdef Column make_timestamp_column( DataType type_, size_type size, MaskArg mask, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -44,7 +43,7 @@ cpdef Column make_duration_column( DataType type_, size_type size, MaskArg mask, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -52,18 +51,18 @@ cpdef Column make_fixed_width_column( DataType type_, size_type size, MaskArg mask, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) cpdef Column make_empty_column( MakeEmptyColumnOperand type_or_id, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) cpdef Column make_empty_lists_column( DataType child_type, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) diff --git a/python/pylibcudf/pylibcudf/column_factories.pyi b/python/pylibcudf/pylibcudf/column_factories.pyi index 66d46d88949..a9e92c5f823 100644 --- a/python/pylibcudf/pylibcudf/column_factories.pyi +++ b/python/pylibcudf/pylibcudf/column_factories.pyi @@ -1,53 +1,53 @@ # SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.types import DataType, MaskState, TypeId +from pylibcudf.utils import CudaStreamLike def make_numeric_column( type_: DataType, size: int, mstate: MaskState, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def make_fixed_point_column( type_: DataType, size: int, mstate: MaskState, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def make_timestamp_column( type_: DataType, size: int, mstate: MaskState, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def make_duration_column( type_: DataType, size: int, mstate: MaskState, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def make_fixed_width_column( type_: DataType, size: int, mstate: MaskState, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def make_empty_column( type_or_id: DataType | TypeId, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def make_empty_lists_column( child_type: DataType, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/column_factories.pyx b/python/pylibcudf/pylibcudf/column_factories.pyx index 0848f1aff03..45d590f4106 100644 --- a/python/pylibcudf/pylibcudf/column_factories.pyx +++ b/python/pylibcudf/pylibcudf/column_factories.pyx @@ -20,6 +20,7 @@ from .types cimport DataType, type_id from .types import MaskState, TypeId from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ @@ -34,7 +35,7 @@ __all__ = [ cpdef Column make_empty_column( MakeEmptyColumnOperand type_or_id, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Creates an empty column of the specified type. @@ -53,7 +54,7 @@ cpdef Column make_empty_column( """ cdef unique_ptr[column] result cdef type_id id - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) mr = _get_memory_resource(mr) if MakeEmptyColumnOperand is object: @@ -75,14 +76,14 @@ cpdef Column make_empty_column( raise TypeError( "Must pass a TypeId or DataType" ) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column make_numeric_column( DataType type_, size_type size, MaskArg mstate, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Creates an empty numeric column. @@ -102,7 +103,8 @@ cpdef Column make_numeric_column( state = mstate else: raise TypeError("Invalid mask argument") - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -110,17 +112,17 @@ cpdef Column make_numeric_column( type_.c_obj, size, state, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column make_fixed_point_column( DataType type_, size_type size, MaskArg mstate, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): @@ -136,7 +138,8 @@ cpdef Column make_fixed_point_column( state = mstate else: raise TypeError("Invalid mask argument") - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -144,18 +147,18 @@ cpdef Column make_fixed_point_column( type_.c_obj, size, state, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column make_timestamp_column( DataType type_, size_type size, MaskArg mstate, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): @@ -171,7 +174,8 @@ cpdef Column make_timestamp_column( state = mstate else: raise TypeError("Invalid mask argument") - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -179,18 +183,18 @@ cpdef Column make_timestamp_column( type_.c_obj, size, state, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column make_duration_column( DataType type_, size_type size, MaskArg mstate, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): @@ -206,7 +210,8 @@ cpdef Column make_duration_column( state = mstate else: raise TypeError("Invalid mask argument") - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -214,18 +219,18 @@ cpdef Column make_duration_column( type_.c_obj, size, state, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column make_fixed_width_column( DataType type_, size_type size, MaskArg mstate, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): @@ -241,7 +246,8 @@ cpdef Column make_fixed_width_column( state = mstate else: raise TypeError("Invalid mask argument") - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -249,16 +255,16 @@ cpdef Column make_fixed_width_column( type_.c_obj, size, state, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column make_empty_lists_column( DataType child_type, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Creates an empty column of the specified type. @@ -276,10 +282,10 @@ cpdef Column make_empty_lists_column( An empty Column """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) mr = _get_memory_resource(mr) with nogil: result = cpp_make_empty_lists_column(child_type.c_obj) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/concatenate.pxd b/python/pylibcudf/pylibcudf/concatenate.pxd index 60adf27c9a3..60189ba4406 100644 --- a/python/pylibcudf/pylibcudf/concatenate.pxd +++ b/python/pylibcudf/pylibcudf/concatenate.pxd @@ -1,9 +1,8 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from .table cimport Table -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource @@ -11,4 +10,4 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource # unify the column and table paths without using runtime dispatch instead. In this case # we choose to prioritize API consistency over performance, so we use the same function # with a bit of runtime dispatch overhead. -cpdef concatenate(list objects, Stream stream=*, DeviceMemoryResource mr=*) +cpdef concatenate(list objects, object stream = *, DeviceMemoryResource mr=*) diff --git a/python/pylibcudf/pylibcudf/concatenate.pyi b/python/pylibcudf/pylibcudf/concatenate.pyi index 18e8bff2e2f..59379e01c46 100644 --- a/python/pylibcudf/pylibcudf/concatenate.pyi +++ b/python/pylibcudf/pylibcudf/concatenate.pyi @@ -1,14 +1,14 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.table import Table +from pylibcudf.utils import CudaStreamLike def concatenate[ColumnOrTable: (Column, Table)]( objects: list[ColumnOrTable], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> ColumnOrTable: ... diff --git a/python/pylibcudf/pylibcudf/concatenate.pyx b/python/pylibcudf/pylibcudf/concatenate.pyx index 36fa0984a68..9921d5b1a39 100644 --- a/python/pylibcudf/pylibcudf/concatenate.pyx +++ b/python/pylibcudf/pylibcudf/concatenate.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -16,10 +16,11 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from .column cimport Column from .table cimport Table from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["concatenate"] -cpdef concatenate(list objects, Stream stream=None, DeviceMemoryResource mr=None): +cpdef concatenate(list objects, object stream=None, DeviceMemoryResource mr=None): """Concatenate columns or tables. Parameters @@ -41,7 +42,8 @@ cpdef concatenate(list objects, Stream stream=None, DeviceMemoryResource mr=None cdef vector[column_view] c_columns cdef vector[table_view] c_tables - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) cdef unique_ptr[column] c_col_result @@ -53,17 +55,17 @@ cpdef concatenate(list objects, Stream stream=None, DeviceMemoryResource mr=None with nogil: c_tbl_result = cpp_concatenate.concatenate( - c_tables, stream.view(), mr.get_mr() + c_tables, _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_tbl_result), stream, mr) + return Table.from_libcudf(move(c_tbl_result), _stream, mr) elif isinstance(objects[0], Column): for column in objects: c_columns.push_back((column).view()) with nogil: c_col_result = cpp_concatenate.concatenate( - c_columns, stream.view(), mr.get_mr() + c_columns, _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_col_result), stream, mr) + return Column.from_libcudf(move(c_col_result), _stream, mr) else: raise ValueError("input must be a list of Columns or Tables") diff --git a/python/pylibcudf/pylibcudf/contiguous_split.pxd b/python/pylibcudf/pylibcudf/contiguous_split.pxd index a294e70a4a6..95259723dfa 100644 --- a/python/pylibcudf/pylibcudf/contiguous_split.pxd +++ b/python/pylibcudf/pylibcudf/contiguous_split.pxd @@ -32,13 +32,13 @@ cdef class HostBuffer: cdef class PackedColumns: cdef unique_ptr[packed_columns] c_obj - cdef Stream stream + cdef object stream cdef DeviceMemoryResource mr @staticmethod cdef PackedColumns from_libcudf( unique_ptr[packed_columns] data, - Stream stream, + object stream, DeviceMemoryResource mr ) cpdef tuple release(self) @@ -58,10 +58,10 @@ cdef class ChunkedPack: cpdef PackedColumns pack(Table input) -cpdef Table unpack(PackedColumns input, Stream stream=*) +cpdef Table unpack(PackedColumns input, object stream = *) cpdef Table unpack_from_memoryviews( memoryview metadata, object gpu_data, - Stream stream=*, + object stream = *, ) diff --git a/python/pylibcudf/pylibcudf/contiguous_split.pyi b/python/pylibcudf/pylibcudf/contiguous_split.pyi index df241c079ae..6e0e653b5bb 100644 --- a/python/pylibcudf/pylibcudf/contiguous_split.pyi +++ b/python/pylibcudf/pylibcudf/contiguous_split.pyi @@ -2,28 +2,30 @@ # SPDX-License-Identifier: Apache-2.0 from rmm.mr import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.gpumemoryview import gpumemoryview from pylibcudf.span import Span from pylibcudf.table import Table +from pylibcudf.utils import CudaStreamLike class PackedColumns: def __init__(self): ... def release( - self, stream: Stream | None = None + self, stream: CudaStreamLike | None = None ) -> tuple[memoryview[bytes], gpumemoryview]: ... def pack( input: Table, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> PackedColumns: ... -def unpack(input: PackedColumns, stream: Stream | None = None) -> Table: ... +def unpack( + input: PackedColumns, stream: CudaStreamLike | None = None +) -> Table: ... def unpack_from_memoryviews( metadata: memoryview[bytes], gpu_data: Span, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, ) -> Table: ... class ChunkedPack: @@ -32,7 +34,7 @@ class ChunkedPack: def create( input: Table, user_buffer_size: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, temp_mr: DeviceMemoryResource | None = None, ) -> ChunkedPack: ... def has_next(self) -> bool: ... diff --git a/python/pylibcudf/pylibcudf/contiguous_split.pyx b/python/pylibcudf/pylibcudf/contiguous_split.pyx index 6b24def5dc8..239d89d6470 100644 --- a/python/pylibcudf/pylibcudf/contiguous_split.pyx +++ b/python/pylibcudf/pylibcudf/contiguous_split.pyx @@ -15,6 +15,8 @@ from cuda.bindings.cyruntime cimport ( cudaError_t, cudaMemcpyAsync, cudaMemcpyKind, + cudaStream_t, + cudaStreamSynchronize, ) from pylibcudf.libcudf.contiguous_split cimport ( @@ -27,7 +29,6 @@ from pylibcudf.libcudf.table.table cimport table from pylibcudf.libcudf.table.table_view cimport table_view from pylibcudf.libcudf.utilities.span cimport device_span -from rmm.librmm.cuda_stream_view cimport cuda_stream_view from rmm.pylibrmm.device_buffer cimport DeviceBuffer from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream @@ -36,6 +37,7 @@ from .gpumemoryview cimport gpumemoryview from .table cimport Table from .span import is_span from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ @@ -105,7 +107,7 @@ cdef class PackedColumns: @staticmethod cdef PackedColumns from_libcudf( unique_ptr[packed_columns] data, - Stream stream, + object stream, DeviceMemoryResource mr ): """Create a Python PackedColumns from a libcudf packed_columns.""" @@ -163,7 +165,7 @@ cdef class ChunkedPack: def create( Table input, size_t user_buffer_size, - Stream stream=None, + object stream=None, DeviceMemoryResource temp_mr=None, ): """ @@ -184,16 +186,16 @@ cdef class ChunkedPack: ------- New ChunkedPack object. """ - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) temp_mr = _get_memory_resource(temp_mr) cdef unique_ptr[chunked_pack] obj = chunked_pack.create( - input.view(), user_buffer_size, stream.view(), temp_mr.get_mr() + input.view(), user_buffer_size, _stream.view().value(), temp_mr.get_mr() ) cdef ChunkedPack out = ChunkedPack.__new__(ChunkedPack) out.table = input out.mr = temp_mr - out.stream = stream + out.stream = _stream out.c_obj = move(obj) return out @@ -292,7 +294,8 @@ cdef class ChunkedPack: dereference(self.c_obj).get_total_contiguous_size() ) ) - cdef cuda_stream_view stream = self.stream.view() + cdef Stream py_stream = self.stream + cdef cudaStream_t stream = py_stream.view().value() with nogil: while dereference(self.c_obj).has_next(): size = dereference(self.c_obj).next(d_span) @@ -301,22 +304,22 @@ cdef class ChunkedPack: d_span.data(), size, cudaMemcpyKind.cudaMemcpyDeviceToHost, - stream.value(), + stream, ) offset += size if err != cudaError.cudaSuccess: - stream.synchronize() + cudaStreamSynchronize(stream) raise RuntimeError( f"Memcpy in pack_to_host failed error: {err}" ) - stream.synchronize() + cudaStreamSynchronize(stream) return ( self.build_metadata(), memoryview(HostBuffer.from_unique_ptr(move(h_buf))), ) -cpdef PackedColumns pack(Table input, Stream stream=None, DeviceMemoryResource mr=None): +cpdef PackedColumns pack(Table input, object stream=None, DeviceMemoryResource mr=None): """Deep-copy a table into a serialized contiguous memory format. Later use `unpack` or `unpack_from_memoryviews` to unpack the serialized @@ -346,16 +349,17 @@ cpdef PackedColumns pack(Table input, Stream stream=None, DeviceMemoryResource m For details, see :cpp:func:`pack`. """ cdef unique_ptr[packed_columns] pack - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: pack = move(make_unique[packed_columns]( - cpp_pack(input.view(), stream.view(), mr.get_mr()) + cpp_pack(input.view(), _cs, mr.get_mr()) )) - return PackedColumns.from_libcudf(move(pack), stream, mr) + return PackedColumns.from_libcudf(move(pack), _stream, mr) -cpdef Table unpack(PackedColumns input, Stream stream=None): +cpdef Table unpack(PackedColumns input, object stream=None): """Deserialize the result of `pack`. Copies the result of a serialized table into a table. @@ -375,16 +379,16 @@ cpdef Table unpack(PackedColumns input, Stream stream=None): Copy of the packed columns. """ cdef table_view v - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) with nogil: v = cpp_unpack(dereference(input.c_obj)) - return Table.from_table_view_of_arbitrary(v, input, stream) + return Table.from_table_view_of_arbitrary(v, input, _stream) cpdef Table unpack_from_memoryviews( memoryview metadata, object gpu_data, - Stream stream=None, + object stream=None, ): """Deserialize the result of `pack`. @@ -406,7 +410,7 @@ cpdef Table unpack_from_memoryviews( Table Copy of the packed columns. """ - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) cdef device_span[uint8_t] d_span = _get_device_span(gpu_data) if metadata.nbytes == 0: @@ -416,7 +420,7 @@ cpdef Table unpack_from_memoryviews( # used for any operations. return Table.from_libcudf( make_unique[table](table_view()), - stream, + _stream, _get_memory_resource(), ) @@ -428,4 +432,4 @@ cpdef Table unpack_from_memoryviews( cdef table_view v with nogil: v = cpp_unpack(metadata_ptr, gpu_data_ptr) - return Table.from_table_view_of_arbitrary(v, gpu_data, stream) + return Table.from_table_view_of_arbitrary(v, gpu_data, _stream) diff --git a/python/pylibcudf/pylibcudf/copying.pxd b/python/pylibcudf/pylibcudf/copying.pxd index caaa590de15..4143e846994 100644 --- a/python/pylibcudf/pylibcudf/copying.pxd +++ b/python/pylibcudf/pylibcudf/copying.pxd @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp cimport bool as cbool @@ -9,7 +9,6 @@ from pylibcudf.libcudf.copying cimport ( from pylibcudf.libcudf.types cimport size_type from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream from .column cimport Column from .scalar cimport Scalar @@ -40,7 +39,7 @@ cpdef Table gather( Table source_table, Column gather_map, out_of_bounds_policy bounds_policy, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -48,19 +47,19 @@ cpdef Table scatter( TableOrListOfScalars source, Column scatter_map, Table target_table, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef ColumnOrTable empty_like( - ColumnOrTable input, Stream stream=*, DeviceMemoryResource mr=* + ColumnOrTable input, object stream = *, DeviceMemoryResource mr=* ) cpdef Column allocate_like( Column input_column, mask_allocation_policy policy, size=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -70,7 +69,7 @@ cpdef Column copy_range_in_place( size_type input_begin, size_type input_end, size_type target_begin, - Stream stream=*, + object stream = *, ) cpdef Column copy_range( @@ -79,7 +78,7 @@ cpdef Column copy_range( size_type input_begin, size_type input_end, size_type target_begin, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -87,19 +86,19 @@ cpdef Column shift( Column input, size_type offset, Scalar fill_value, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) -cpdef list slice(ColumnOrTable input, list indices, Stream stream=*) +cpdef list slice(ColumnOrTable input, list indices, object stream = *) -cpdef list split(ColumnOrTable input, list splits, Stream stream=*) +cpdef list split(ColumnOrTable input, list splits, object stream = *) cpdef Column copy_if_else( LeftCopyIfElseOperand lhs, RightCopyIfElseOperand rhs, Column boolean_mask, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -107,13 +106,13 @@ cpdef Table boolean_mask_scatter( TableOrListOfScalars input, Table target, Column boolean_mask, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef Scalar get_element( Column input_column, size_type index, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/copying.pyi b/python/pylibcudf/pylibcudf/copying.pyi index 04acecc2f1b..bdff6cddad5 100644 --- a/python/pylibcudf/pylibcudf/copying.pyi +++ b/python/pylibcudf/pylibcudf/copying.pyi @@ -1,15 +1,15 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from enum import IntEnum from typing import TypeVar from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar from pylibcudf.table import Table +from pylibcudf.utils import CudaStreamLike class MaskAllocationPolicy(IntEnum): NEVER = ... @@ -26,26 +26,26 @@ def gather( source_table: Table, gather_map: Column, bounds_policy: OutOfBoundsPolicy, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def scatter( source: Table | list[Scalar], scatter_map: Column, target_table: Table, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def empty_like( input: ColumnOrTable, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> ColumnOrTable: ... def allocate_like( input_column: Column, policy: MaskAllocationPolicy, size: int | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def copy_range_in_place( @@ -54,7 +54,7 @@ def copy_range_in_place( input_begin: int, input_end: int, target_begin: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, ) -> Column: ... def copy_range( input_column: Column, @@ -62,39 +62,43 @@ def copy_range( input_begin: int, input_end: int, target_begin: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def shift( input: Column, offset: int, fill_value: Scalar, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def slice( - input: ColumnOrTable, indices: list[int], stream: Stream | None = None + input: ColumnOrTable, + indices: list[int], + stream: CudaStreamLike | None = None, ) -> list[ColumnOrTable]: ... def split( - input: ColumnOrTable, splits: list[int], stream: Stream | None = None + input: ColumnOrTable, + splits: list[int], + stream: CudaStreamLike | None = None, ) -> list[ColumnOrTable]: ... def copy_if_else( lhs: Column | Scalar, rhs: Column | Scalar, boolean_mask: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def boolean_mask_scatter( input: Table | list[Scalar], target: Table, boolean_mask: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def get_element( input_column: Column, index: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Scalar: ... diff --git a/python/pylibcudf/pylibcudf/copying.pyx b/python/pylibcudf/pylibcudf/copying.pyx index f8f44e03938..30be1ea7d0a 100644 --- a/python/pylibcudf/pylibcudf/copying.pyx +++ b/python/pylibcudf/pylibcudf/copying.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from cython.operator import dereference @@ -40,6 +40,7 @@ from .column cimport Column from .scalar cimport Scalar from .table cimport Table from .utils cimport _as_vector, _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ @@ -64,7 +65,7 @@ cpdef Table gather( Table source_table, Column gather_map, out_of_bounds_policy bounds_policy, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Select rows from source_table according to the provided gather_map. @@ -94,7 +95,8 @@ cpdef Table gather( If the gather_map contains nulls. """ cdef unique_ptr[table] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -102,18 +104,18 @@ cpdef Table gather( source_table.view(), gather_map.view(), bounds_policy, - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef Table scatter( TableOrListOfScalars source, Column scatter_map, Table target_table, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Scatter from source into target_table according to scatter_map. @@ -155,7 +157,8 @@ cpdef Table scatter( """ cdef unique_ptr[table] c_result cdef vector[reference_wrapper[const scalar]] source_scalars - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if TableOrListOfScalars is Table: @@ -164,7 +167,7 @@ cpdef Table scatter( source.view(), scatter_map.view(), target_table.view(), - stream.view(), + _cs, mr.get_mr() ) else: @@ -174,14 +177,14 @@ cpdef Table scatter( source_scalars, scatter_map.view(), target_table.view(), - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef ColumnOrTable empty_like( - ColumnOrTable input, Stream stream=None, DeviceMemoryResource mr=None + ColumnOrTable input, object stream=None, DeviceMemoryResource mr=None ): """Create an empty column or table with the same type as ``input``. @@ -201,23 +204,23 @@ cpdef ColumnOrTable empty_like( """ cdef unique_ptr[table] c_tbl_result cdef unique_ptr[column] c_col_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) mr = _get_memory_resource(mr) if ColumnOrTable is Column: with nogil: c_col_result = cpp_copying.empty_like(input.view()) - return Column.from_libcudf(move(c_col_result), stream, mr) + return Column.from_libcudf(move(c_col_result), _stream, mr) else: with nogil: c_tbl_result = cpp_copying.empty_like(input.view()) - return Table.from_libcudf(move(c_tbl_result), stream, mr) + return Table.from_libcudf(move(c_tbl_result), _stream, mr) cpdef Column allocate_like( Column input_column, mask_allocation_policy policy, size=None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Allocate a column with the same type as input_column. @@ -244,7 +247,8 @@ cpdef Column allocate_like( cdef unique_ptr[column] c_result cdef size_type c_size = size if size is not None else input_column.size() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -252,11 +256,11 @@ cpdef Column allocate_like( input_column.view(), c_size, policy, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column copy_range_in_place( @@ -265,7 +269,7 @@ cpdef Column copy_range_in_place( size_type input_begin, size_type input_end, size_type target_begin, - Stream stream=None + object stream=None ): """Copy a range of elements from input_column to target_column. @@ -301,7 +305,8 @@ cpdef Column copy_range_in_place( """ cdef mutable_column_view target_view = target_column.mutable_view() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() with nogil: cpp_copying.copy_range_in_place( @@ -310,7 +315,7 @@ cpdef Column copy_range_in_place( input_begin, input_end, target_begin, - stream.view() + _cs ) target_column.set_null_count(target_view.null_count()) @@ -321,7 +326,7 @@ cpdef Column copy_range( size_type input_begin, size_type input_end, size_type target_begin, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Copy a range of elements from input_column to target_column. @@ -357,7 +362,8 @@ cpdef Column copy_range( If target and source have different types. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -367,18 +373,18 @@ cpdef Column copy_range( input_begin, input_end, target_begin, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column shift( Column input, size_type offset, Scalar fill_value, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Shift the elements of input by offset. @@ -409,7 +415,8 @@ cpdef Column shift( of fixed width or string type. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -417,13 +424,13 @@ cpdef Column shift( input.view(), offset, dereference(fill_value.c_obj), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) -cpdef list slice(ColumnOrTable input, list indices, Stream stream=None): +cpdef list slice(ColumnOrTable input, list indices, object stream=None): """Slice input according to indices. For details on the implementation, see :cpp:func:`slice`. @@ -454,11 +461,12 @@ cpdef list slice(ColumnOrTable input, list indices, Stream stream=None): cdef vector[column_view] c_col_result cdef vector[table_view] c_tbl_result cdef int i - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() if ColumnOrTable is Column: with nogil: - c_col_result = cpp_copying.slice(input.view(), c_indices, stream.view()) + c_col_result = cpp_copying.slice(input.view(), c_indices, _cs) return [ Column.from_column_view(c_col_result[i], input) @@ -466,7 +474,7 @@ cpdef list slice(ColumnOrTable input, list indices, Stream stream=None): ] else: with nogil: - c_tbl_result = cpp_copying.slice(input.view(), c_indices, stream.view()) + c_tbl_result = cpp_copying.slice(input.view(), c_indices, _cs) return [ Table.from_table_view(c_tbl_result[i], input) @@ -474,7 +482,7 @@ cpdef list slice(ColumnOrTable input, list indices, Stream stream=None): ] -cpdef list split(ColumnOrTable input, list splits, Stream stream=None): +cpdef list split(ColumnOrTable input, list splits, object stream=None): """Split input into multiple. For details on the implementation, see :cpp:func:`split`. @@ -497,11 +505,12 @@ cpdef list split(ColumnOrTable input, list splits, Stream stream=None): cdef vector[column_view] c_col_result cdef vector[table_view] c_tbl_result cdef int i - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() if ColumnOrTable is Column: with nogil: - c_col_result = cpp_copying.split(input.view(), c_splits, stream.view()) + c_col_result = cpp_copying.split(input.view(), c_splits, _cs) return [ Column.from_column_view(c_col_result[i], input) @@ -509,7 +518,7 @@ cpdef list split(ColumnOrTable input, list splits, Stream stream=None): ] else: with nogil: - c_tbl_result = cpp_copying.split(input.view(), c_splits, stream.view()) + c_tbl_result = cpp_copying.split(input.view(), c_splits, _cs) return [ Table.from_table_view(c_tbl_result[i], input) @@ -521,7 +530,7 @@ cpdef Column copy_if_else( LeftCopyIfElseOperand lhs, RightCopyIfElseOperand rhs, Column boolean_mask, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Copy elements from lhs or rhs into a new column according to boolean_mask. @@ -556,7 +565,8 @@ cpdef Column copy_if_else( columns), or if lhs and rhs are not of the same length (if both are columns). """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if LeftCopyIfElseOperand is Column and RightCopyIfElseOperand is Column: @@ -565,7 +575,7 @@ cpdef Column copy_if_else( lhs.view(), rhs.view(), boolean_mask.view(), - stream.view(), + _cs, mr.get_mr() ) elif LeftCopyIfElseOperand is Column and RightCopyIfElseOperand is Scalar: @@ -574,7 +584,7 @@ cpdef Column copy_if_else( lhs.view(), dereference(rhs.c_obj), boolean_mask.view(), - stream.view(), + _cs, mr.get_mr() ) elif LeftCopyIfElseOperand is Scalar and RightCopyIfElseOperand is Column: @@ -583,7 +593,7 @@ cpdef Column copy_if_else( dereference(lhs.c_obj), rhs.view(), boolean_mask.view(), - stream.view(), + _cs, mr.get_mr() ) else: @@ -592,18 +602,18 @@ cpdef Column copy_if_else( dereference(lhs.c_obj), dereference(rhs.c_obj), boolean_mask.view(), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef Table boolean_mask_scatter( TableOrListOfScalars input, Table target, Column boolean_mask, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Scatter rows from input into target according to boolean_mask. @@ -641,7 +651,8 @@ cpdef Table boolean_mask_scatter( """ cdef unique_ptr[table] result cdef vector[reference_wrapper[const scalar]] source_scalars - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if TableOrListOfScalars is Table: @@ -650,7 +661,7 @@ cpdef Table boolean_mask_scatter( input.view(), target.view(), boolean_mask.view(), - stream.view(), + _cs, mr.get_mr() ) else: @@ -660,17 +671,17 @@ cpdef Table boolean_mask_scatter( source_scalars, target.view(), boolean_mask.view(), - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(result), stream, mr) + return Table.from_libcudf(move(result), _stream, mr) cpdef Scalar get_element( Column input_column, size_type index, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Get the element at index from input_column. @@ -697,12 +708,13 @@ cpdef Scalar get_element( If index is out of bounds. """ cdef unique_ptr[scalar] c_output - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_output = cpp_copying.get_element( - input_column.view(), index, stream.view(), mr.get_mr() + input_column.view(), index, _cs, mr.get_mr() ) return Scalar.from_libcudf(move(c_output)) diff --git a/python/pylibcudf/pylibcudf/datetime.pxd b/python/pylibcudf/pylibcudf/datetime.pxd index 1a93ee62c43..d7d15f0c19f 100644 --- a/python/pylibcudf/pylibcudf/datetime.pxd +++ b/python/pylibcudf/pylibcudf/datetime.pxd @@ -1,11 +1,10 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.libcudf.datetime cimport datetime_component, rounding_frequency from pylibcudf.scalar cimport Scalar from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream ctypedef fused ColumnOrScalar: Column @@ -14,54 +13,54 @@ ctypedef fused ColumnOrScalar: cpdef Column extract_datetime_component( Column input, datetime_component component, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) cpdef Column ceil_datetimes( Column input, rounding_frequency freq, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) cpdef Column floor_datetimes( Column input, rounding_frequency freq, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) cpdef Column round_datetimes( Column input, rounding_frequency freq, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) cpdef Column add_calendrical_months( Column timestamps, ColumnOrScalar months, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) cpdef Column day_of_year( - Column input, Stream stream = *, DeviceMemoryResource mr = * + Column input, object stream = *, DeviceMemoryResource mr = * ) cpdef Column is_leap_year( - Column input, Stream stream = *, DeviceMemoryResource mr = * + Column input, object stream = *, DeviceMemoryResource mr = * ) cpdef Column last_day_of_month( - Column input, Stream stream = *, DeviceMemoryResource mr = * + Column input, object stream = *, DeviceMemoryResource mr = * ) cpdef Column extract_quarter( - Column input, Stream stream = *, DeviceMemoryResource mr = * + Column input, object stream = *, DeviceMemoryResource mr = * ) cpdef Column days_in_month( - Column input, Stream stream = *, DeviceMemoryResource mr = * + Column input, object stream = *, DeviceMemoryResource mr = * ) diff --git a/python/pylibcudf/pylibcudf/datetime.pyi b/python/pylibcudf/pylibcudf/datetime.pyi index abcc608daa4..e671d2d18cf 100644 --- a/python/pylibcudf/pylibcudf/datetime.pyi +++ b/python/pylibcudf/pylibcudf/datetime.pyi @@ -1,13 +1,13 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from enum import IntEnum from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar +from pylibcudf.utils import CudaStreamLike class DatetimeComponent(IntEnum): YEAR = ... @@ -33,55 +33,55 @@ class RoundingFrequency(IntEnum): def extract_datetime_component( input: Column, component: DatetimeComponent, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def ceil_datetimes( input: Column, freq: RoundingFrequency, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def floor_datetimes( input: Column, freq: RoundingFrequency, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def round_datetimes( input: Column, freq: RoundingFrequency, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def add_calendrical_months( input: Column, months: Column | Scalar, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def day_of_year( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def is_leap_year( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def last_day_of_month( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def extract_quarter( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def days_in_month( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/datetime.pyx b/python/pylibcudf/pylibcudf/datetime.pyx index 2a837c5b749..1e5270bad92 100644 --- a/python/pylibcudf/pylibcudf/datetime.pyx +++ b/python/pylibcudf/pylibcudf/datetime.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr from libcpp.utility cimport move @@ -30,6 +30,7 @@ from rmm.pylibrmm.stream cimport Stream from .column cimport Column from .scalar cimport Scalar from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "DatetimeComponent", @@ -49,7 +50,7 @@ __all__ = [ cpdef Column extract_datetime_component( Column input, datetime_component component, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -73,19 +74,20 @@ cpdef Column extract_datetime_component( """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: result = cpp_extract_datetime_component( - input.view(), component, stream.view(), mr.get_mr() + input.view(), component, _cs, mr.get_mr() ) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column ceil_datetimes( Column input, rounding_frequency freq, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -109,17 +111,18 @@ cpdef Column ceil_datetimes( """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - result = cpp_ceil_datetimes(input.view(), freq, stream.view(), mr.get_mr()) - return Column.from_libcudf(move(result), stream, mr) + result = cpp_ceil_datetimes(input.view(), freq, _cs, mr.get_mr()) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column floor_datetimes( Column input, rounding_frequency freq, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -143,17 +146,18 @@ cpdef Column floor_datetimes( """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - result = cpp_floor_datetimes(input.view(), freq, stream.view(), mr.get_mr()) - return Column.from_libcudf(move(result), stream, mr) + result = cpp_floor_datetimes(input.view(), freq, _cs, mr.get_mr()) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column round_datetimes( Column input, rounding_frequency freq, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -177,17 +181,18 @@ cpdef Column round_datetimes( """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - result = cpp_round_datetimes(input.view(), freq, stream.view(), mr.get_mr()) - return Column.from_libcudf(move(result), stream, mr) + result = cpp_round_datetimes(input.view(), freq, _cs, mr.get_mr()) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column add_calendrical_months( Column input, ColumnOrScalar months, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -216,7 +221,8 @@ cpdef Column add_calendrical_months( cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -224,13 +230,13 @@ cpdef Column add_calendrical_months( input.view(), months.view() if ColumnOrScalar is Column else dereference(months.get()), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column day_of_year( - Column input, Stream stream=None, DeviceMemoryResource mr=None + Column input, object stream=None, DeviceMemoryResource mr=None ): """ Computes the day number since the start of @@ -253,15 +259,16 @@ cpdef Column day_of_year( """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - result = cpp_day_of_year(input.view(), stream.view(), mr.get_mr()) - return Column.from_libcudf(move(result), stream, mr) + result = cpp_day_of_year(input.view(), _cs, mr.get_mr()) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column is_leap_year( - Column input, Stream stream=None, DeviceMemoryResource mr=None + Column input, object stream=None, DeviceMemoryResource mr=None ): """ Check if the year of the given date is a leap year. @@ -283,15 +290,16 @@ cpdef Column is_leap_year( """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - result = cpp_is_leap_year(input.view(), stream.view(), mr.get_mr()) - return Column.from_libcudf(move(result), stream, mr) + result = cpp_is_leap_year(input.view(), _cs, mr.get_mr()) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column last_day_of_month( - Column input, Stream stream=None, DeviceMemoryResource mr=None + Column input, object stream=None, DeviceMemoryResource mr=None ): """ Computes the last day of the month. @@ -313,15 +321,16 @@ cpdef Column last_day_of_month( """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - result = cpp_last_day_of_month(input.view(), stream.view(), mr.get_mr()) - return Column.from_libcudf(move(result), stream, mr) + result = cpp_last_day_of_month(input.view(), _cs, mr.get_mr()) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column extract_quarter( - Column input, Stream stream=None, DeviceMemoryResource mr=None + Column input, object stream=None, DeviceMemoryResource mr=None ): """ Returns the quarter (ie. a value from {1, 2, 3, 4}) @@ -343,15 +352,16 @@ cpdef Column extract_quarter( """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - result = cpp_extract_quarter(input.view(), stream.view(), mr.get_mr()) - return Column.from_libcudf(move(result), stream, mr) + result = cpp_extract_quarter(input.view(), _cs, mr.get_mr()) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column days_in_month( - Column input, Stream stream=None, DeviceMemoryResource mr=None + Column input, object stream=None, DeviceMemoryResource mr=None ): """ Extract the number of days in the month. @@ -372,12 +382,13 @@ cpdef Column days_in_month( """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - result = cpp_days_in_month(input.view(), stream.view(), mr.get_mr()) - return Column.from_libcudf(move(result), stream, mr) + result = cpp_days_in_month(input.view(), _cs, mr.get_mr()) + return Column.from_libcudf(move(result), _stream, mr) DatetimeComponent.__str__ = DatetimeComponent.__repr__ RoundingFrequency.__str__ = RoundingFrequency.__repr__ diff --git a/python/pylibcudf/pylibcudf/experimental/_join_streams.pxd b/python/pylibcudf/pylibcudf/experimental/_join_streams.pxd index db9ca865197..832d572b467 100644 --- a/python/pylibcudf/pylibcudf/experimental/_join_streams.pxd +++ b/python/pylibcudf/pylibcudf/experimental/_join_streams.pxd @@ -1,6 +1,5 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.stream cimport Stream -cpdef void join_streams(list streams, Stream stream) +cpdef void join_streams(list streams, object stream) diff --git a/python/pylibcudf/pylibcudf/experimental/_join_streams.pyi b/python/pylibcudf/pylibcudf/experimental/_join_streams.pyi index 522239c6a80..c9c2ba79e36 100644 --- a/python/pylibcudf/pylibcudf/experimental/_join_streams.pyi +++ b/python/pylibcudf/pylibcudf/experimental/_join_streams.pyi @@ -1,6 +1,8 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.stream import Stream +from pylibcudf.utils import CudaStreamLike -def join_streams(streams: list[Stream], stream: Stream) -> None: ... +def join_streams( + streams: list[CudaStreamLike], stream: CudaStreamLike +) -> None: ... diff --git a/python/pylibcudf/pylibcudf/experimental/_join_streams.pyx b/python/pylibcudf/pylibcudf/experimental/_join_streams.pyx index 7f3d2f228fb..d9efcb19ed9 100644 --- a/python/pylibcudf/pylibcudf/experimental/_join_streams.pyx +++ b/python/pylibcudf/pylibcudf/experimental/_join_streams.pyx @@ -1,21 +1,22 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 +from cuda.bindings.cyruntime cimport cudaStream_t from libcpp.vector cimport vector from pylibcudf.libcudf.detail.utilities cimport stream_pool as cpp_stream_pool +from pylibcudf.libcudf.detail.utilities.stream_pool cimport const_cudaStream_t from pylibcudf.libcudf.utilities.span cimport host_span -from rmm.librmm.cuda_stream_view cimport cuda_stream_view from rmm.pylibrmm.stream cimport Stream -ctypedef const cuda_stream_view const_cuda_stream_view +from ..utils cimport _get_stream __all__ = ["join_streams"] -cpdef void join_streams(list streams, Stream stream): +cpdef void join_streams(list streams, object stream): """Synchronize a stream to an event on a set of streams. This function synchronizes the joined stream with the waited-on streams @@ -42,15 +43,16 @@ cpdef void join_streams(list streams, Stream stream): >>> plc.experimental.join_streams([stream1, stream2], join_stream) >>> # ... continue work on join_stream ... """ - cdef Stream c_stream = stream - cdef vector[cuda_stream_view] c_streams + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() + cdef vector[cudaStream_t] c_streams c_streams.reserve(len(streams)) for s in streams: - c_streams.push_back((s).view()) + c_streams.push_back((_get_stream(s)).view().value()) with nogil: cpp_stream_pool.join_streams( - host_span[const_cuda_stream_view](c_streams.data(), c_streams.size()), - c_stream.view() + host_span[const_cudaStream_t](c_streams.data(), c_streams.size()), + _cs ) diff --git a/python/pylibcudf/pylibcudf/filling.pxd b/python/pylibcudf/pylibcudf/filling.pxd index b90d567b2c2..acb92e0212a 100644 --- a/python/pylibcudf/pylibcudf/filling.pxd +++ b/python/pylibcudf/pylibcudf/filling.pxd @@ -1,7 +1,6 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.libcudf.types cimport size_type -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from .column cimport Column @@ -17,7 +16,7 @@ cpdef Column fill( size_type begin, size_type end, Scalar value, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -26,21 +25,21 @@ cpdef void fill_in_place( size_type c_begin, size_type c_end, Scalar value, - Stream stream = *, + object stream = *, ) cpdef Column sequence( size_type size, Scalar init, Scalar step, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) cpdef Table repeat( Table input_table, ColumnOrSize count, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -48,6 +47,6 @@ cpdef Column calendrical_month_sequence( size_type n, Scalar init, size_type months, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) diff --git a/python/pylibcudf/pylibcudf/filling.pyi b/python/pylibcudf/pylibcudf/filling.pyi index a1023f8016c..2789ecd5aca 100644 --- a/python/pylibcudf/pylibcudf/filling.pyi +++ b/python/pylibcudf/pylibcudf/filling.pyi @@ -1,32 +1,33 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.stream import Stream - from pylibcudf.column import Column from pylibcudf.scalar import Scalar from pylibcudf.table import Table +from pylibcudf.utils import CudaStreamLike def fill( destination: Column, begin: int, end: int, value: Scalar, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, ) -> Column: ... def fill_in_place( destination: Column, begin: int, end: int, value: Scalar, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, ) -> None: ... def sequence( - size: int, init: Scalar, step: Scalar, stream: Stream | None = None + size: int, init: Scalar, step: Scalar, stream: CudaStreamLike | None = None ) -> Column: ... def repeat( - input_table: Table, count: Column | int, stream: Stream | None = None + input_table: Table, + count: Column | int, + stream: CudaStreamLike | None = None, ) -> Table: ... def calendrical_month_sequence( - n: int, init: Scalar, months: int, stream: Stream | None = None + n: int, init: Scalar, months: int, stream: CudaStreamLike | None = None ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/filling.pyx b/python/pylibcudf/pylibcudf/filling.pyx index 68e4862dfb8..ce6002eb24e 100644 --- a/python/pylibcudf/pylibcudf/filling.pyx +++ b/python/pylibcudf/pylibcudf/filling.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from cython.operator cimport dereference @@ -22,6 +22,7 @@ from .column cimport Column from .scalar cimport Scalar from .table cimport Table from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ @@ -37,7 +38,7 @@ cpdef Column fill( size_type begin, size_type end, Scalar value, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): @@ -68,7 +69,8 @@ cpdef Column fill( cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -77,17 +79,17 @@ cpdef Column fill( begin, end, dereference(( value).c_obj), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef void fill_in_place( Column destination, size_type begin, size_type end, Scalar value, - Stream stream=None, + object stream=None, ): """Fill destination column in place from begin to end with value. @@ -112,7 +114,8 @@ cpdef void fill_in_place( None """ - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() cdef mutable_column_view c_destination = destination.mutable_view() with nogil: @@ -121,7 +124,7 @@ cpdef void fill_in_place( begin, end, dereference(value.c_obj), - stream.view() + _cs ) destination.set_null_count(c_destination.null_count()) @@ -129,7 +132,7 @@ cpdef Column sequence( size_type size, Scalar init, Scalar step, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Create a sequence column of size ``size`` with initial value ``init`` and step @@ -157,7 +160,8 @@ cpdef Column sequence( cdef unique_ptr[column] result cdef size_type c_size = size - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -165,16 +169,16 @@ cpdef Column sequence( c_size, dereference(init.c_obj), dereference(step.c_obj), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef Table repeat( Table input_table, ColumnOrSize count, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Repeat rows of a Table. @@ -203,7 +207,8 @@ cpdef Table repeat( cdef unique_ptr[table] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if ColumnOrSize is Column: @@ -211,7 +216,7 @@ cpdef Table repeat( result = cpp_repeat( input_table.view(), count.view(), - stream.view(), + _cs, mr.get_mr() ) if ColumnOrSize is size_type: @@ -219,17 +224,17 @@ cpdef Table repeat( result = cpp_repeat( input_table.view(), count, - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(result), stream, mr) + return Table.from_libcudf(move(result), _stream, mr) cpdef Column calendrical_month_sequence( size_type n, Scalar init, size_type months, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): @@ -256,7 +261,8 @@ cpdef Column calendrical_month_sequence( cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -264,7 +270,7 @@ cpdef Column calendrical_month_sequence( n, dereference(init.c_obj), months, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/groupby.pxd b/python/pylibcudf/pylibcudf/groupby.pxd index b5654ff6df8..a46146a145a 100644 --- a/python/pylibcudf/pylibcudf/groupby.pxd +++ b/python/pylibcudf/pylibcudf/groupby.pxd @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -19,7 +19,6 @@ from pylibcudf.libcudf.table.table cimport table from pylibcudf.libcudf.types cimport null_order, order from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream from .column cimport Column from .table cimport Table @@ -46,31 +45,31 @@ cdef class GroupBy: cdef unique_ptr[vector[null_order]] _null_precedence cpdef tuple aggregate( - self, list requests, Stream stream=*, DeviceMemoryResource mr=* + self, list requests, object stream = *, DeviceMemoryResource mr=* ) - cpdef tuple scan(self, list requests, Stream stream=*, DeviceMemoryResource mr=*) + cpdef tuple scan(self, list requests, object stream = *, DeviceMemoryResource mr=*) cpdef tuple shift( self, Table values, list offset, list fill_values, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef tuple replace_nulls( self, Table values, list replace_policies, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef tuple get_groups( - self, Table values=*, Stream stream=*, DeviceMemoryResource mr=* + self, Table values=*, object stream = *, DeviceMemoryResource mr=* ) @staticmethod cdef tuple _parse_outputs( pair[unique_ptr[table], vector[aggregation_result]] c_res, - Stream stream, + object stream, DeviceMemoryResource mr, ) diff --git a/python/pylibcudf/pylibcudf/groupby.pyi b/python/pylibcudf/pylibcudf/groupby.pyi index 75322706187..01c732175f4 100644 --- a/python/pylibcudf/pylibcudf/groupby.pyi +++ b/python/pylibcudf/pylibcudf/groupby.pyi @@ -1,8 +1,7 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.aggregation import Aggregation from pylibcudf.column import Column @@ -10,6 +9,7 @@ from pylibcudf.replace import ReplacePolicy from pylibcudf.scalar import Scalar from pylibcudf.table import Table from pylibcudf.types import NullOrder, NullPolicy, Order, Sorted +from pylibcudf.utils import CudaStreamLike class GroupByRequest: def __init__( @@ -28,13 +28,13 @@ class GroupBy: def aggregate( self, requests: list[GroupByRequest], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[Table, list[Table]]: ... def scan( self, requests: list[GroupByRequest], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[Table, list[Table]]: ... def shift( @@ -42,19 +42,19 @@ class GroupBy: values: Table, offset: list[int], fill_values: list[Scalar], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[Table, Table]: ... def replace_nulls( self, value: Table, replace_policies: list[ReplacePolicy], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[Table, Table]: ... def get_groups( self, values: Table | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[list[int], Table, Table]: ... diff --git a/python/pylibcudf/pylibcudf/groupby.pyx b/python/pylibcudf/pylibcudf/groupby.pyx index 94a292996a0..4b2f842a360 100644 --- a/python/pylibcudf/pylibcudf/groupby.pyx +++ b/python/pylibcudf/pylibcudf/groupby.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from cython.operator cimport dereference @@ -28,6 +28,7 @@ from .column cimport Column from .table cimport Table from .types cimport null_order, null_policy, order, sorted from .utils cimport _as_vector, _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["GroupBy", "GroupByRequest"] @@ -141,12 +142,13 @@ cdef class GroupBy: @staticmethod cdef tuple _parse_outputs( pair[unique_ptr[table], vector[aggregation_result]] c_res, - Stream stream, + object stream, DeviceMemoryResource mr, ): # Convert libcudf aggregation/scan outputs into pylibcudf objects. # This function is for internal use only. - cdef Table group_keys = Table.from_libcudf(move(c_res.first), stream, mr) + cdef Stream _stream = stream + cdef Table group_keys = Table.from_libcudf(move(c_res.first), _stream, mr) cdef int i, j cdef list results = [] @@ -155,13 +157,13 @@ cdef class GroupBy: inner_results = [] for j in range(c_res.second[i].results.size()): inner_results.append( - Column.from_libcudf(move(c_res.second[i].results[j]), stream, mr) + Column.from_libcudf(move(c_res.second[i].results[j]), _stream, mr) ) results.append(Table(inner_results)) return group_keys, results cpdef tuple aggregate( - self, list requests, Stream stream=None, DeviceMemoryResource mr=None + self, list requests, object stream=None, DeviceMemoryResource mr=None ): """Compute aggregations on columns. @@ -189,19 +191,20 @@ cdef class GroupBy: c_requests.push_back(move(request._to_libcudf_agg_request())) cdef pair[unique_ptr[table], vector[aggregation_result]] c_res - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) # TODO: Need to capture C++ exceptions indicating that an invalid type was used. # We rely on libcudf to tell us this rather than checking the types beforehand # ourselves. with nogil: c_res = dereference(self.c_obj).aggregate( - c_requests, stream.view(), mr.get_mr() + c_requests, _cs, mr.get_mr() ) - return GroupBy._parse_outputs(move(c_res), stream, mr) + return GroupBy._parse_outputs(move(c_res), _stream, mr) cpdef tuple scan( - self, list requests, Stream stream=None, DeviceMemoryResource mr=None + self, list requests, object stream=None, DeviceMemoryResource mr=None ): """Compute scans on columns. @@ -229,18 +232,23 @@ cdef class GroupBy: c_requests.push_back(move(request._to_libcudf_scan_request())) cdef pair[unique_ptr[table], vector[aggregation_result]] c_res - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_res = dereference(self.c_obj).scan(c_requests, stream.view(), mr.get_mr()) - return GroupBy._parse_outputs(move(c_res), stream, mr) + c_res = dereference(self.c_obj).scan( + c_requests, + _cs, + mr.get_mr(), + ) + return GroupBy._parse_outputs(move(c_res), _stream, mr) cpdef tuple shift( self, Table values, list offset, list fill_values, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Compute shifts on columns. @@ -269,26 +277,27 @@ cdef class GroupBy: cdef vector[size_type] c_offset = offset cdef pair[unique_ptr[table], unique_ptr[table]] c_res - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_res = dereference(self.c_obj).shift( values.view(), c_offset, c_fill_values, - stream.view(), + _cs, mr.get_mr() ) return ( - Table.from_libcudf(move(c_res.first), stream, mr), - Table.from_libcudf(move(c_res.second), stream, mr), + Table.from_libcudf(move(c_res.first), _stream, mr), + Table.from_libcudf(move(c_res.second), _stream, mr), ) cpdef tuple replace_nulls( self, Table value, list replace_policies, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Replace nulls in columns. @@ -312,22 +321,23 @@ cdef class GroupBy: """ cdef pair[unique_ptr[table], unique_ptr[table]] c_res cdef vector[replace_policy] c_replace_policies = replace_policies - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_res = dereference(self.c_obj).replace_nulls( value.view(), c_replace_policies, - stream.view(), + _cs, mr.get_mr() ) return ( - Table.from_libcudf(move(c_res.first), stream, mr), - Table.from_libcudf(move(c_res.second), stream, mr), + Table.from_libcudf(move(c_res.first), _stream, mr), + Table.from_libcudf(move(c_res.second), _stream, mr), ) cpdef tuple get_groups( - self, Table values=None, Stream stream=None, DeviceMemoryResource mr=None + self, Table values=None, object stream=None, DeviceMemoryResource mr=None ): """Get the grouped keys and values labels for each row. @@ -352,24 +362,24 @@ cdef class GroupBy: cdef groups c_groups cdef table_view empty_view - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) mr = _get_memory_resource(mr) if values: c_groups = dereference(self.c_obj).get_groups( - values.view(), stream.view(), mr.get_mr() + values.view(), _stream.view().value(), mr.get_mr() ) return ( c_groups.offsets, - Table.from_libcudf(move(c_groups.keys), stream, mr), - Table.from_libcudf(move(c_groups.values), stream, mr), + Table.from_libcudf(move(c_groups.keys), _stream, mr), + Table.from_libcudf(move(c_groups.values), _stream, mr), ) else: # c_groups.values is nullptr - call get_groups with empty table view c_groups = dereference(self.c_obj).get_groups( - empty_view, stream.view(), mr.get_mr() + empty_view, _stream.view().value(), mr.get_mr() ) return ( c_groups.offsets, - Table.from_libcudf(move(c_groups.keys), stream, mr), + Table.from_libcudf(move(c_groups.keys), _stream, mr), None, ) diff --git a/python/pylibcudf/pylibcudf/hashing.pxd b/python/pylibcudf/pylibcudf/hashing.pxd index 4febd6e4949..b824f2dbcb8 100644 --- a/python/pylibcudf/pylibcudf/hashing.pxd +++ b/python/pylibcudf/pylibcudf/hashing.pxd @@ -1,9 +1,8 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libc.stdint cimport uint32_t, uint64_t from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream from .column cimport Column from .table cimport Table @@ -12,34 +11,34 @@ from .table cimport Table cpdef Column murmurhash3_x86_32( Table input, uint32_t seed=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) cpdef Table murmurhash3_x64_128( Table input, uint64_t seed=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) cpdef Column xxhash_32( Table input, uint32_t seed=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) cpdef Column xxhash_64( Table input, uint64_t seed=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) -cpdef Column md5(Table input, Stream stream=*, DeviceMemoryResource mr=*) -cpdef Column sha1(Table input, Stream stream=*, DeviceMemoryResource mr=*) -cpdef Column sha224(Table input, Stream stream=*, DeviceMemoryResource mr=*) -cpdef Column sha256(Table input, Stream stream=*, DeviceMemoryResource mr=*) -cpdef Column sha384(Table input, Stream stream=*, DeviceMemoryResource mr=*) -cpdef Column sha512(Table input, Stream stream=*, DeviceMemoryResource mr=*) +cpdef Column md5(Table input, object stream = *, DeviceMemoryResource mr=*) +cpdef Column sha1(Table input, object stream = *, DeviceMemoryResource mr=*) +cpdef Column sha224(Table input, object stream = *, DeviceMemoryResource mr=*) +cpdef Column sha256(Table input, object stream = *, DeviceMemoryResource mr=*) +cpdef Column sha384(Table input, object stream = *, DeviceMemoryResource mr=*) +cpdef Column sha512(Table input, object stream = *, DeviceMemoryResource mr=*) diff --git a/python/pylibcudf/pylibcudf/hashing.pyi b/python/pylibcudf/pylibcudf/hashing.pyi index 1b8d055368a..dae03796b9c 100644 --- a/python/pylibcudf/pylibcudf/hashing.pyi +++ b/python/pylibcudf/pylibcudf/hashing.pyi @@ -1,67 +1,67 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from typing import Final from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.table import Table +from pylibcudf.utils import CudaStreamLike LIBCUDF_DEFAULT_HASH_SEED: Final[int] def murmurhash3_x86_32( input: Table, seed: int = ..., - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def murmurhash3_x64_128( input: Table, seed: int = ..., - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def xxhash_32( input: Table, seed: int = ..., - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def xxhash_64( input: Table, seed: int = ..., - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def md5( input: Table, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def sha1( input: Table, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def sha224( input: Table, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def sha256( input: Table, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def sha384( input: Table, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def sha512( input: Table, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/hashing.pyx b/python/pylibcudf/pylibcudf/hashing.pyx index d9db52720bf..941393cf949 100644 --- a/python/pylibcudf/pylibcudf/hashing.pyx +++ b/python/pylibcudf/pylibcudf/hashing.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libc.stdint cimport uint32_t, uint64_t from libcpp.memory cimport unique_ptr @@ -24,6 +24,7 @@ from rmm.pylibrmm.stream cimport Stream from .column cimport Column from .table cimport Table from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "LIBCUDF_DEFAULT_HASH_SEED", @@ -44,7 +45,7 @@ LIBCUDF_DEFAULT_HASH_SEED = DEFAULT_HASH_SEED cpdef Column murmurhash3_x86_32( Table input, uint32_t seed=DEFAULT_HASH_SEED, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Computes the MurmurHash3 32-bit hash value of each row in the given table. @@ -65,24 +66,25 @@ cpdef Column murmurhash3_x86_32( """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_murmurhash3_x86_32( input.view(), seed, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Table murmurhash3_x64_128( Table input, uint64_t seed=DEFAULT_HASH_SEED, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Computes the MurmurHash3 64-bit hash value of each row in the given table. @@ -103,24 +105,25 @@ cpdef Table murmurhash3_x64_128( """ cdef unique_ptr[table] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_murmurhash3_x64_128( input.view(), seed, - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef Column xxhash_32( Table input, uint32_t seed=DEFAULT_HASH_SEED, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Computes the xxHash 32-bit hash value of each row in the given table. @@ -142,24 +145,25 @@ cpdef Column xxhash_32( cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_xxhash_32( input.view(), seed, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column xxhash_64( Table input, uint64_t seed=DEFAULT_HASH_SEED, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Computes the xxHash 64-bit hash value of each row in the given table. @@ -181,23 +185,24 @@ cpdef Column xxhash_64( cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_xxhash_64( input.view(), seed, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column md5( Table input, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Computes the MD5 hash value of each row in the given table. @@ -220,16 +225,17 @@ cpdef Column md5( cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_md5(input.view(), stream.view(), mr.get_mr()) - return Column.from_libcudf(move(c_result), stream, mr) + c_result = cpp_md5(input.view(), _cs, mr.get_mr()) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column sha1( Table input, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Computes the SHA-1 hash value of each row in the given table. @@ -250,17 +256,18 @@ cpdef Column sha1( """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_sha1(input.view(), stream.view(), mr.get_mr()) - return Column.from_libcudf(move(c_result), stream, mr) + c_result = cpp_sha1(input.view(), _cs, mr.get_mr()) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column sha224( Table input, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Computes the SHA-224 hash value of each row in the given table. @@ -281,17 +288,18 @@ cpdef Column sha224( """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_sha224(input.view(), stream.view(), mr.get_mr()) - return Column.from_libcudf(move(c_result), stream, mr) + c_result = cpp_sha224(input.view(), _cs, mr.get_mr()) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column sha256( Table input, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Computes the SHA-256 hash value of each row in the given table. @@ -312,17 +320,18 @@ cpdef Column sha256( """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_sha256(input.view(), stream.view(), mr.get_mr()) - return Column.from_libcudf(move(c_result), stream, mr) + c_result = cpp_sha256(input.view(), _cs, mr.get_mr()) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column sha384( Table input, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Computes the SHA-384 hash value of each row in the given table. @@ -343,17 +352,18 @@ cpdef Column sha384( """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_sha384(input.view(), stream.view(), mr.get_mr()) - return Column.from_libcudf(move(c_result), stream, mr) + c_result = cpp_sha384(input.view(), _cs, mr.get_mr()) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column sha512( Table input, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Computes the SHA-512 hash value of each row in the given table. @@ -374,9 +384,10 @@ cpdef Column sha512( """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_sha512(input.view(), stream.view(), mr.get_mr()) - return Column.from_libcudf(move(c_result), stream, mr) + c_result = cpp_sha512(input.view(), _cs, mr.get_mr()) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/interop.pxd b/python/pylibcudf/pylibcudf/interop.pxd index dfa62233541..942b9e806bc 100644 --- a/python/pylibcudf/pylibcudf/interop.pxd +++ b/python/pylibcudf/pylibcudf/interop.pxd @@ -1,12 +1,11 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.table cimport Table -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource cpdef Table from_dlpack( - object managed_tensor, Stream stream=*, DeviceMemoryResource mr=* + object managed_tensor, object stream = *, DeviceMemoryResource mr=* ) -cpdef object to_dlpack(Table input, Stream stream=*, DeviceMemoryResource mr=*) +cpdef object to_dlpack(Table input, object stream = *, DeviceMemoryResource mr=*) diff --git a/python/pylibcudf/pylibcudf/interop.pyi b/python/pylibcudf/pylibcudf/interop.pyi index 0c10d71ec4f..34fe9394f7d 100644 --- a/python/pylibcudf/pylibcudf/interop.pyi +++ b/python/pylibcudf/pylibcudf/interop.pyi @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from collections.abc import Iterable, Mapping @@ -8,12 +8,12 @@ from typing import Any, overload import pyarrow as pa from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar from pylibcudf.table import Table from pylibcudf.types import DataType +from pylibcudf.utils import CudaStreamLike @dataclass class ColumnMetadata: @@ -33,14 +33,14 @@ def from_arrow( obj: pa.Array[Any], *, data_type: DataType | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... @overload def from_arrow( obj: pa.Table, *, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... @overload @@ -67,11 +67,11 @@ def to_arrow( ) -> pa.Scalar[Any]: ... def from_dlpack( managed_tensor: Any, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def to_dlpack( input: Table, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Any: ... diff --git a/python/pylibcudf/pylibcudf/interop.pyx b/python/pylibcudf/pylibcudf/interop.pyx index ffc14415470..23c47bb090f 100644 --- a/python/pylibcudf/pylibcudf/interop.pyx +++ b/python/pylibcudf/pylibcudf/interop.pyx @@ -23,6 +23,7 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from .table cimport Table from .utils cimport _get_stream, _get_memory_resource from ._interop_helpers import ColumnMetadata +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ @@ -35,7 +36,7 @@ __all__ = [ cpdef Table from_dlpack( - object managed_tensor, Stream stream=None, DeviceMemoryResource mr=None + object managed_tensor, object stream=None, DeviceMemoryResource mr=None ): """ Convert a DLPack DLTensor into a cudf table. @@ -65,7 +66,8 @@ cpdef Table from_dlpack( if dlpack_tensor is NULL: raise ValueError("PyCapsule object contained a NULL pointer") PyCapsule_SetName(managed_tensor, "used_dltensor") - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) # Note: A copy is always performed when converting the dlpack @@ -74,14 +76,14 @@ cpdef Table from_dlpack( # TODO: https://github.com/rapidsai/cudf/issues/10874 # TODO: https://github.com/rapidsai/cudf/issues/10849 with nogil: - c_result = cpp_from_dlpack(dlpack_tensor, stream.view(), mr.get_mr()) + c_result = cpp_from_dlpack(dlpack_tensor, _cs, mr.get_mr()) - cdef Table result = Table.from_libcudf(move(c_result), stream, mr) + cdef Table result = Table.from_libcudf(move(c_result), _stream, mr) dlpack_tensor.deleter(dlpack_tensor) return result -cpdef object to_dlpack(Table input, Stream stream=None, DeviceMemoryResource mr=None): +cpdef object to_dlpack(Table input, object stream=None, DeviceMemoryResource mr=None): """ Convert a cudf table into a DLPack DLTensor. @@ -109,11 +111,12 @@ cpdef object to_dlpack(Table input, Stream stream=None, DeviceMemoryResource mr= "Input is required to have null count as zero." ) cdef DLManagedTensor *dlpack_tensor - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - dlpack_tensor = cpp_to_dlpack(input.view(), stream.view(), mr.get_mr()) + dlpack_tensor = cpp_to_dlpack(input.view(), _cs, mr.get_mr()) return PyCapsule_New( dlpack_tensor, diff --git a/python/pylibcudf/pylibcudf/io/avro.pxd b/python/pylibcudf/pylibcudf/io/avro.pxd index d76f2c1e628..0e8cb7ee283 100644 --- a/python/pylibcudf/pylibcudf/io/avro.pxd +++ b/python/pylibcudf/pylibcudf/io/avro.pxd @@ -1,6 +1,5 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from pylibcudf.io.types cimport SourceInfo, TableWithMetadata @@ -29,5 +28,5 @@ cdef class AvroReaderOptionsBuilder: cpdef AvroReaderOptions build(self) cpdef TableWithMetadata read_avro( - AvroReaderOptions options, Stream stream = *, DeviceMemoryResource mr=* + AvroReaderOptions options, object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/io/avro.pyi b/python/pylibcudf/pylibcudf/io/avro.pyi index d7b6c87d388..7e41c39a2be 100644 --- a/python/pylibcudf/pylibcudf/io/avro.pyi +++ b/python/pylibcudf/pylibcudf/io/avro.pyi @@ -1,9 +1,9 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.io.types import SourceInfo, TableWithMetadata +from pylibcudf.utils import CudaStreamLike __all__ = ["AvroReaderOptions", "AvroReaderOptionsBuilder", "read_avro"] @@ -21,6 +21,6 @@ class AvroReaderOptionsBuilder: def read_avro( options: AvroReaderOptions, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> TableWithMetadata: ... diff --git a/python/pylibcudf/pylibcudf/io/avro.pyx b/python/pylibcudf/pylibcudf/io/avro.pyx index 9c5e2c05b11..f2bd021cdde 100644 --- a/python/pylibcudf/pylibcudf/io/avro.pyx +++ b/python/pylibcudf/pylibcudf/io/avro.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.string cimport string @@ -6,6 +6,7 @@ from libcpp.utility cimport move from libcpp.vector cimport vector from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from pylibcudf.io.types cimport SourceInfo, TableWithMetadata @@ -152,7 +153,7 @@ cdef class AvroReaderOptionsBuilder: cpdef TableWithMetadata read_avro( AvroReaderOptions options, - Stream stream = None, + object stream = None, DeviceMemoryResource mr=None, ): """ @@ -173,8 +174,9 @@ cpdef TableWithMetadata read_avro( Device memory resource used to allocate the returned table's device memory. """ cdef Stream s = _get_stream(stream) + cdef cudaStream_t _cs = s.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = move(cpp_read_avro(options.c_obj, s.view(), mr.get_mr())) + c_result = move(cpp_read_avro(options.c_obj, _cs, mr.get_mr())) return TableWithMetadata.from_libcudf(c_result, s, mr) diff --git a/python/pylibcudf/pylibcudf/io/csv.pxd b/python/pylibcudf/pylibcudf/io/csv.pxd index 2f138e3aaa1..4293452311d 100644 --- a/python/pylibcudf/pylibcudf/io/csv.pxd +++ b/python/pylibcudf/pylibcudf/io/csv.pxd @@ -1,10 +1,9 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp cimport bool from libcpp.string cimport string from libcpp.vector cimport vector -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from pylibcudf.io.types cimport SinkInfo, SourceInfo, TableWithMetadata @@ -74,7 +73,7 @@ cdef class CsvReaderOptionsBuilder: cpdef CsvReaderOptions build(self) cpdef TableWithMetadata read_csv( - CsvReaderOptions options, Stream stream = *, DeviceMemoryResource mr=* + CsvReaderOptions options, object stream = *, DeviceMemoryResource mr=* ) cdef class CsvWriterOptions: @@ -98,6 +97,6 @@ cdef class CsvWriterOptionsBuilder: cpdef CsvWriterOptions build(self) -cpdef void write_csv(CsvWriterOptions options, Stream stream = *) +cpdef void write_csv(CsvWriterOptions options, object stream = *) cpdef bool is_supported_write_csv(DataType type) diff --git a/python/pylibcudf/pylibcudf/io/csv.pyi b/python/pylibcudf/pylibcudf/io/csv.pyi index ade964da509..41465b3ba43 100644 --- a/python/pylibcudf/pylibcudf/io/csv.pyi +++ b/python/pylibcudf/pylibcudf/io/csv.pyi @@ -4,7 +4,6 @@ from typing import Self from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.io.types import ( CompressionType, @@ -15,6 +14,7 @@ from pylibcudf.io.types import ( ) from pylibcudf.table import Table from pylibcudf.types import DataType +from pylibcudf.utils import CudaStreamLike class CsvReaderOptions: def __init__(self): ... @@ -61,10 +61,12 @@ class CsvReaderOptionsBuilder: def read_csv( options: CsvReaderOptions, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> TableWithMetadata: ... -def write_csv(options: CsvWriterOptions, stream: Stream | None = None): ... +def write_csv( + options: CsvWriterOptions, stream: CudaStreamLike | None = None +): ... class CsvWriterOptions: def __init__(self): ... diff --git a/python/pylibcudf/pylibcudf/io/csv.pyx b/python/pylibcudf/pylibcudf/io/csv.pyx index 749cd45fcb5..1c3ae9cb0bf 100644 --- a/python/pylibcudf/pylibcudf/io/csv.pyx +++ b/python/pylibcudf/pylibcudf/io/csv.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp cimport bool @@ -8,6 +8,7 @@ from libcpp.utility cimport move from libcpp.vector cimport vector from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from pylibcudf.io.types cimport SourceInfo, SinkInfo, TableWithMetadata @@ -672,7 +673,7 @@ cdef class CsvReaderOptionsBuilder: cpdef TableWithMetadata read_csv( CsvReaderOptions options, - Stream stream = None, + object stream = None, DeviceMemoryResource mr=None, ): """ @@ -694,9 +695,10 @@ cpdef TableWithMetadata read_csv( """ cdef table_with_metadata c_result cdef Stream s = _get_stream(stream) + cdef cudaStream_t _cs = s.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = move(cpp_read_csv(options.c_obj, s.view(), mr.get_mr())) + c_result = move(cpp_read_csv(options.c_obj, _cs, mr.get_mr())) cdef TableWithMetadata tbl_meta = TableWithMetadata.from_libcudf(c_result, s, mr) return tbl_meta @@ -882,7 +884,7 @@ cdef class CsvWriterOptionsBuilder: cpdef void write_csv( CsvWriterOptions options, - Stream stream = None, + object stream = None, ): """ Write to CSV format. @@ -900,8 +902,9 @@ cpdef void write_csv( CUDA stream used for device memory operations and kernel launches """ cdef Stream s = _get_stream(stream) + cdef cudaStream_t _cs = s.view().value() with nogil: - cpp_write_csv(move(options.c_obj), s.view()) + cpp_write_csv(move(options.c_obj), _cs) cpdef bool is_supported_write_csv(DataType type): diff --git a/python/pylibcudf/pylibcudf/io/experimental/hybrid_scan.pxd b/python/pylibcudf/pylibcudf/io/experimental/hybrid_scan.pxd index 298b36651c3..8c471831823 100644 --- a/python/pylibcudf/pylibcudf/io/experimental/hybrid_scan.pxd +++ b/python/pylibcudf/pylibcudf/io/experimental/hybrid_scan.pxd @@ -32,5 +32,5 @@ cdef class FileMetaData: cdef class HybridScanReader: cdef unique_ptr[cpp_hybrid_scan_reader] c_obj - cdef Stream stream + cdef Stream _stream cdef DeviceMemoryResource mr diff --git a/python/pylibcudf/pylibcudf/io/experimental/hybrid_scan.pyi b/python/pylibcudf/pylibcudf/io/experimental/hybrid_scan.pyi index 0f0429a66db..6f1fbc250d8 100644 --- a/python/pylibcudf/pylibcudf/io/experimental/hybrid_scan.pyi +++ b/python/pylibcudf/pylibcudf/io/experimental/hybrid_scan.pyi @@ -4,13 +4,13 @@ from enum import IntEnum from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.io.parquet import ParquetReaderOptions from pylibcudf.io.text import ByteRangeInfo from pylibcudf.io.types import TableWithMetadata from pylibcudf.span import Span +from pylibcudf.utils import CudaStreamLike class UseDataPageMask(IntEnum): YES: int @@ -44,7 +44,7 @@ class HybridScanReader: self, row_group_indices: list[int], options: ParquetReaderOptions, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, ) -> list[int]: ... def secondary_filters_byte_ranges( self, row_group_indices: list[int], options: ParquetReaderOptions @@ -54,20 +54,20 @@ class HybridScanReader: dictionary_page_data: list[Span], row_group_indices: list[int], options: ParquetReaderOptions, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, ) -> list[int]: ... def filter_row_groups_with_bloom_filters( self, bloom_filter_data: list[Span], row_group_indices: list[int], options: ParquetReaderOptions, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, ) -> list[int]: ... def build_row_mask_with_page_index_stats( self, row_group_indices: list[int], options: ParquetReaderOptions, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def filter_column_chunks_byte_ranges( @@ -80,7 +80,7 @@ class HybridScanReader: row_mask: Column, mask_data_pages: UseDataPageMask, options: ParquetReaderOptions, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> TableWithMetadata: ... def payload_column_chunks_byte_ranges( @@ -93,7 +93,7 @@ class HybridScanReader: row_mask: Column, mask_data_pages: UseDataPageMask, options: ParquetReaderOptions, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> TableWithMetadata: ... def all_column_chunks_byte_ranges( @@ -104,7 +104,7 @@ class HybridScanReader: row_group_indices: list[int], column_chunk_data: list[Span], options: ParquetReaderOptions, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> TableWithMetadata: ... def setup_chunking_for_filter_columns( @@ -116,7 +116,7 @@ class HybridScanReader: mask_data_pages: UseDataPageMask, column_chunk_data: list[Span], options: ParquetReaderOptions, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> None: ... def materialize_filter_columns_chunk( @@ -132,7 +132,7 @@ class HybridScanReader: mask_data_pages: UseDataPageMask, column_chunk_data: list[Span], options: ParquetReaderOptions, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> None: ... def materialize_payload_columns_chunk( diff --git a/python/pylibcudf/pylibcudf/io/experimental/hybrid_scan.pyx b/python/pylibcudf/pylibcudf/io/experimental/hybrid_scan.pyx index beb28f6a1b0..4d25a05d362 100644 --- a/python/pylibcudf/pylibcudf/io/experimental/hybrid_scan.pyx +++ b/python/pylibcudf/pylibcudf/io/experimental/hybrid_scan.pyx @@ -225,7 +225,7 @@ cdef class HybridScanReader: self, list row_group_indices, ParquetReaderOptions options, - Stream stream=None + object stream=None ): """Filter row groups using column chunk statistics. @@ -243,7 +243,7 @@ cdef class HybridScanReader: list[int] Filtered row group indices """ - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) cdef vector[size_type] indices_vec = row_group_indices cdef vector[size_type] filtered = ( self.c_obj.get()[0].filter_row_groups_with_stats( @@ -251,7 +251,7 @@ cdef class HybridScanReader: indices_vec.data(), indices_vec.size() ), options.c_obj, - stream.view() + _stream.view().value() ) ) return list(filtered) @@ -295,7 +295,7 @@ cdef class HybridScanReader: list dictionary_page_data, list row_group_indices, ParquetReaderOptions options, - Stream stream=None + object stream=None ): """Filter row groups using column chunk dictionary pages. @@ -316,7 +316,7 @@ cdef class HybridScanReader: Filtered row group indices """ cdef vector[device_span[const_uint8_t]] spans_vec - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) for span in dictionary_page_data: spans_vec.push_back(_get_device_span(span)) @@ -329,7 +329,7 @@ cdef class HybridScanReader: ), host_span[const_size_type](indices_vec.data(), indices_vec.size()), options.c_obj, - stream.view() + _stream.view().value() ) return list(filtered) @@ -338,7 +338,7 @@ cdef class HybridScanReader: list bloom_filter_data, list row_group_indices, ParquetReaderOptions options, - Stream stream=None + object stream=None ): """Filter row groups using column chunk bloom filters. @@ -359,7 +359,7 @@ cdef class HybridScanReader: Filtered row group indices """ cdef vector[device_span[const_uint8_t]] spans_vec - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) for span in bloom_filter_data: spans_vec.push_back(_get_device_span(span)) @@ -372,7 +372,7 @@ cdef class HybridScanReader: ), host_span[const_size_type](indices_vec.data(), indices_vec.size()), options.c_obj, - stream.view() + _stream.view().value() ) return list(filtered) @@ -380,7 +380,7 @@ cdef class HybridScanReader: self, list row_group_indices, ParquetReaderOptions options, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Build a boolean column indicating surviving rows from page stats. @@ -402,16 +402,16 @@ cdef class HybridScanReader: Boolean column indicating surviving rows """ cdef vector[size_type] indices_vec = row_group_indices - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) mr = _get_memory_resource(mr) cdef unique_ptr[column] c_result = \ self.c_obj.get()[0].build_row_mask_with_page_index_stats( host_span[const_size_type](indices_vec.data(), indices_vec.size()), options.c_obj, - stream.view(), + _stream.view().value(), mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) def filter_column_chunks_byte_ranges( self, @@ -447,7 +447,7 @@ cdef class HybridScanReader: Column row_mask, cpp_use_data_page_mask mask_data_pages, ParquetReaderOptions options, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Materialize filter columns and update the row mask. @@ -477,7 +477,7 @@ cdef class HybridScanReader: cdef vector[size_type] indices_vec = row_group_indices cdef vector[device_span[const_uint8_t]] spans_vec - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) mr = _get_memory_resource(mr) for span in column_chunk_data: spans_vec.push_back(_get_device_span(span)) @@ -492,10 +492,10 @@ cdef class HybridScanReader: mask_view, mask_data_pages, options.c_obj, - stream.view(), + _stream.view().value(), mr.get_mr() ) - return TableWithMetadata.from_libcudf(c_result, stream, mr) + return TableWithMetadata.from_libcudf(c_result, _stream, mr) def payload_column_chunks_byte_ranges( self, @@ -531,7 +531,7 @@ cdef class HybridScanReader: Column row_mask, cpp_use_data_page_mask mask_data_pages, ParquetReaderOptions options, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Materialize payload columns and apply the row mask. @@ -561,7 +561,7 @@ cdef class HybridScanReader: cdef vector[size_type] indices_vec = row_group_indices cdef vector[device_span[const_uint8_t]] spans_vec - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) mr = _get_memory_resource(mr) for span in column_chunk_data: spans_vec.push_back(_get_device_span(span)) @@ -576,10 +576,10 @@ cdef class HybridScanReader: mask_view, mask_data_pages, options.c_obj, - stream.view(), + _stream.view().value(), mr.get_mr() ) - return TableWithMetadata.from_libcudf(c_result, stream, mr) + return TableWithMetadata.from_libcudf(c_result, _stream, mr) def all_column_chunks_byte_ranges( self, @@ -613,7 +613,7 @@ cdef class HybridScanReader: list row_group_indices, list column_chunk_data, ParquetReaderOptions options, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Materialize all columns. @@ -639,7 +639,7 @@ cdef class HybridScanReader: cdef vector[size_type] indices_vec = row_group_indices cdef vector[device_span[const_uint8_t]] spans_vec - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) mr = _get_memory_resource(mr) for span in column_chunk_data: spans_vec.push_back(_get_device_span(span)) @@ -650,10 +650,10 @@ cdef class HybridScanReader: spans_vec.data(), spans_vec.size() ), options.c_obj, - stream.view(), + _stream.view().value(), mr.get_mr() ) - return TableWithMetadata.from_libcudf(c_result, stream, mr) + return TableWithMetadata.from_libcudf(c_result, _stream, mr) def setup_chunking_for_filter_columns( self, @@ -664,7 +664,7 @@ cdef class HybridScanReader: cpp_use_data_page_mask mask_data_pages, list column_chunk_data, ParquetReaderOptions options, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Setup chunking information for filter columns. @@ -696,7 +696,7 @@ cdef class HybridScanReader: for span in column_chunk_data: spans_vec.push_back(_get_device_span(span)) - self.stream = _get_stream(stream) + self._stream = _get_stream(stream) self.mr = _get_memory_resource(mr) cdef column_view mask_view = row_mask.view() @@ -710,7 +710,7 @@ cdef class HybridScanReader: spans_vec.data(), spans_vec.size() ), options.c_obj, - self.stream.view(), + self._stream.view().value(), self.mr.get_mr() ) @@ -735,7 +735,7 @@ cdef class HybridScanReader: mask_view ) return TableWithMetadata.from_libcudf( - c_result, self.stream, self.mr + c_result, self._stream, self.mr ) def setup_chunking_for_payload_columns( @@ -747,7 +747,7 @@ cdef class HybridScanReader: cpp_use_data_page_mask mask_data_pages, list column_chunk_data, ParquetReaderOptions options, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Setup chunking information for payload columns. @@ -779,7 +779,7 @@ cdef class HybridScanReader: for span in column_chunk_data: spans_vec.push_back(_get_device_span(span)) - self.stream = _get_stream(stream) + self._stream = _get_stream(stream) self.mr = _get_memory_resource(mr) cdef column_view mask_view = row_mask.view() @@ -793,7 +793,7 @@ cdef class HybridScanReader: spans_vec.data(), spans_vec.size() ), options.c_obj, - self.stream.view(), + self._stream.view().value(), self.mr.get_mr() ) @@ -818,7 +818,7 @@ cdef class HybridScanReader: mask_view ) return TableWithMetadata.from_libcudf( - c_result, self.stream, self.mr + c_result, self._stream, self.mr ) def construct_row_group_passes( diff --git a/python/pylibcudf/pylibcudf/io/json.pxd b/python/pylibcudf/pylibcudf/io/json.pxd index 96bc102ef0b..e46942ea14b 100644 --- a/python/pylibcudf/pylibcudf/io/json.pxd +++ b/python/pylibcudf/pylibcudf/io/json.pxd @@ -1,10 +1,9 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp cimport bool from libcpp.map cimport map from libcpp.vector cimport vector -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from pylibcudf.io.types cimport ( @@ -83,7 +82,7 @@ cdef class JsonReaderOptionsBuilder: cpdef build(self) cpdef TableWithMetadata read_json( - JsonReaderOptions options, Stream stream = *, DeviceMemoryResource mr = * + JsonReaderOptions options, object stream = *, DeviceMemoryResource mr = * ) cpdef TableWithMetadata read_json_from_string_column( @@ -93,7 +92,7 @@ cpdef TableWithMetadata read_json_from_string_column( list dtypes = *, compression_type compression = *, json_recovery_mode_t recovery_mode = *, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *) cdef class JsonWriterOptions: @@ -117,13 +116,13 @@ cdef class JsonWriterOptionsBuilder: cpdef JsonWriterOptionsBuilder utf8_escaped(self, bool val) cpdef JsonWriterOptions build(self) -cpdef void write_json(JsonWriterOptions options, Stream stream = *) +cpdef void write_json(JsonWriterOptions options, object stream = *) cpdef bool is_supported_write_json(DataType type) cpdef tuple chunked_read_json( JsonReaderOptions options, int chunk_size= *, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) diff --git a/python/pylibcudf/pylibcudf/io/json.pyi b/python/pylibcudf/pylibcudf/io/json.pyi index f19da874a0d..a03d8ef407c 100644 --- a/python/pylibcudf/pylibcudf/io/json.pyi +++ b/python/pylibcudf/pylibcudf/io/json.pyi @@ -4,7 +4,6 @@ from collections.abc import Mapping from typing import Self, TypeAlias from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.io.types import ( @@ -17,6 +16,7 @@ from pylibcudf.io.types import ( from pylibcudf.scalar import Scalar from pylibcudf.table import Table from pylibcudf.types import DataType +from pylibcudf.utils import CudaStreamLike ChildNameToTypeMap: TypeAlias = Mapping[str, ChildNameToTypeMap] @@ -73,7 +73,7 @@ class JsonReaderOptionsBuilder: def read_json( options: JsonReaderOptions, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> TableWithMetadata: ... def read_json_from_string_column( @@ -83,7 +83,7 @@ def read_json_from_string_column( dtypes: list | None = None, compression: CompressionType = CompressionType.NONE, recovery_mode: JSONRecoveryMode = JSONRecoveryMode.RECOVER_WITH_NULL, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> TableWithMetadata: ... @@ -105,12 +105,12 @@ class JsonWriterOptionsBuilder: def build(self) -> JsonWriterOptions: ... def write_json( - options: JsonWriterOptions, stream: Stream | None = None + options: JsonWriterOptions, stream: CudaStreamLike | None = None ) -> None: ... def chunked_read_json( options: JsonReaderOptions, chunk_size: int = 100_000_000, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[list[Column], list[str], ChildNameToTypeMap]: ... def is_supported_write_json(type: DataType) -> bool: ... diff --git a/python/pylibcudf/pylibcudf/io/json.pyx b/python/pylibcudf/pylibcudf/io/json.pyx index aa66c6fe5c2..1bce364fdd8 100644 --- a/python/pylibcudf/pylibcudf/io/json.pyx +++ b/python/pylibcudf/pylibcudf/io/json.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp cimport bool from libcpp.map cimport map @@ -49,6 +49,7 @@ from pylibcudf.utils cimport _get_stream from cython.operator import dereference from rmm.pylibrmm.device_buffer cimport DeviceBuffer +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "chunked_read_json", @@ -704,7 +705,7 @@ cdef class JsonReaderOptionsBuilder: cpdef tuple chunked_read_json( JsonReaderOptions options, int chunk_size=100_000_000, - Stream stream = None, + object stream = None, DeviceMemoryResource mr = None, ): """ @@ -735,6 +736,7 @@ cpdef tuple chunked_read_json( child_names = None i = 0 cdef Stream s = _get_stream(stream) + cdef cudaStream_t _cs = s.view().value() mr = _get_memory_resource(mr) while True: options.enable_lines(True) @@ -743,7 +745,7 @@ cpdef tuple chunked_read_json( try: with nogil: - c_result = move(cpp_read_json(options.c_obj, s.view(), mr.get_mr())) + c_result = move(cpp_read_json(options.c_obj, _cs, mr.get_mr())) except (ValueError, OverflowError): break if meta_names is None: @@ -772,7 +774,7 @@ cpdef tuple chunked_read_json( cpdef TableWithMetadata read_json( JsonReaderOptions options, - Stream stream = None, + object stream = None, DeviceMemoryResource mr = None ): """ @@ -797,9 +799,10 @@ cpdef TableWithMetadata read_json( """ cdef table_with_metadata c_result cdef Stream s = _get_stream(stream) + cdef cudaStream_t _cs = s.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = move(cpp_read_json(options.c_obj, s.view(), mr.get_mr())) + c_result = move(cpp_read_json(options.c_obj, _cs, mr.get_mr())) return TableWithMetadata.from_libcudf(c_result, s, mr) @@ -810,7 +813,7 @@ cpdef TableWithMetadata read_json_from_string_column( list dtypes = None, compression_type compression = compression_type.NONE, json_recovery_mode_t recovery_mode = json_recovery_mode_t.RECOVER_WITH_NULL, - Stream stream = None, + object stream = None, DeviceMemoryResource mr = None ): """ @@ -852,7 +855,8 @@ cpdef TableWithMetadata read_json_from_string_column( cdef unique_ptr[column] c_join_string_column cdef column_contents c_contents cdef table_with_metadata c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) # Join the string column into a single string @@ -862,7 +866,7 @@ cpdef TableWithMetadata read_json_from_string_column( input.view(), dereference(c_separator), dereference(c_narep), - stream.view(), + _cs, mr.get_mr() ) ) @@ -870,7 +874,7 @@ cpdef TableWithMetadata read_json_from_string_column( # Create a new source from the joined string data cdef SourceInfo joined_source = SourceInfo( - [DeviceBuffer.c_from_unique_ptr(move(c_contents.data), stream, mr)]) + [DeviceBuffer.c_from_unique_ptr(move(c_contents.data), _stream, mr)]) # Create new options using the joined string as source cdef JsonReaderOptions options = ( @@ -886,9 +890,9 @@ cpdef TableWithMetadata read_json_from_string_column( # Read JSON from the joined string with nogil: - c_result = move(cpp_read_json(options.c_obj, stream.view(), mr.get_mr())) + c_result = move(cpp_read_json(options.c_obj, _cs, mr.get_mr())) - return TableWithMetadata.from_libcudf(c_result, stream, mr) + return TableWithMetadata.from_libcudf(c_result, _stream, mr) cdef class JsonWriterOptions: """ @@ -1090,7 +1094,7 @@ cdef class JsonWriterOptionsBuilder: return json_options -cpdef void write_json(JsonWriterOptions options, Stream stream = None): +cpdef void write_json(JsonWriterOptions options, object stream = None): """ Writes a set of columns to JSON format. @@ -1106,8 +1110,9 @@ cpdef void write_json(JsonWriterOptions options, Stream stream = None): None """ cdef Stream s = _get_stream(stream) + cdef cudaStream_t _cs = s.view().value() with nogil: - cpp_write_json(options.c_obj, s.view()) + cpp_write_json(options.c_obj, _cs) cpdef bool is_supported_write_json(DataType type): """Check if the dtype is supported for JSON writing diff --git a/python/pylibcudf/pylibcudf/io/orc.pxd b/python/pylibcudf/pylibcudf/io/orc.pxd index 24221163917..72ad5aac534 100644 --- a/python/pylibcudf/pylibcudf/io/orc.pxd +++ b/python/pylibcudf/pylibcudf/io/orc.pxd @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libc.stdint cimport uint64_t, int64_t @@ -9,7 +9,6 @@ from libcpp.optional cimport optional from libcpp.string cimport string from libcpp.vector cimport vector -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from pylibcudf.io.types cimport ( @@ -65,7 +64,7 @@ cdef class OrcReaderOptionsBuilder: cpdef OrcReaderOptions build(self) cpdef TableWithMetadata read_orc( - OrcReaderOptions options, Stream stream = *, DeviceMemoryResource mr=* + OrcReaderOptions options, object stream = *, DeviceMemoryResource mr=* ) cdef class OrcColumnStatistics: @@ -89,7 +88,7 @@ cdef class ParsedOrcStatistics: cpdef ParsedOrcStatistics read_parsed_orc_statistics( SourceInfo source_info, - Stream stream=* + object stream = * ) cdef class OrcWriterOptions: @@ -110,7 +109,7 @@ cdef class OrcWriterOptionsBuilder: cpdef OrcWriterOptionsBuilder metadata(self, TableInputMetadata meta) cpdef OrcWriterOptions build(self) -cpdef void write_orc(OrcWriterOptions options, Stream stream = *) +cpdef void write_orc(OrcWriterOptions options, object stream = *) cdef class OrcChunkedWriter: cdef unique_ptr[orc_chunked_writer] c_obj diff --git a/python/pylibcudf/pylibcudf/io/orc.pyi b/python/pylibcudf/pylibcudf/io/orc.pyi index dcf2b731bac..3cb6daff240 100644 --- a/python/pylibcudf/pylibcudf/io/orc.pyi +++ b/python/pylibcudf/pylibcudf/io/orc.pyi @@ -4,7 +4,6 @@ from typing import Any, Self from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.io.types import ( CompressionType, @@ -16,6 +15,7 @@ from pylibcudf.io.types import ( ) from pylibcudf.table import Table from pylibcudf.types import DataType +from pylibcudf.utils import CudaStreamLike class OrcReaderOptions: def set_num_rows(self, nrows: int) -> None: ... @@ -34,7 +34,7 @@ class OrcReaderOptionsBuilder: def read_orc( options: OrcReaderOptions, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> TableWithMetadata: ... @@ -59,7 +59,7 @@ class ParsedOrcStatistics: def read_parsed_orc_statistics( source_info: SourceInfo, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, ) -> ParsedOrcStatistics: ... class OrcWriterOptions: @@ -79,7 +79,7 @@ class OrcWriterOptionsBuilder: def build(self) -> OrcWriterOptions: ... def write_orc( - options: OrcWriterOptions, stream: Stream | None = None + options: OrcWriterOptions, stream: CudaStreamLike | None = None ) -> None: ... def is_supported_read_orc(compression: CompressionType) -> bool: ... def is_supported_write_orc(compression: CompressionType) -> bool: ... @@ -90,7 +90,7 @@ class OrcChunkedWriter: def write(self, table: Table) -> None: ... @staticmethod def from_options( - options: ChunkedOrcWriterOptions, stream: Stream | None = None + options: ChunkedOrcWriterOptions, stream: CudaStreamLike | None = None ) -> OrcChunkedWriter: ... class ChunkedOrcWriterOptions: diff --git a/python/pylibcudf/pylibcudf/io/orc.pyx b/python/pylibcudf/pylibcudf/io/orc.pyx index 8c3687ec232..3a2fabc5683 100644 --- a/python/pylibcudf/pylibcudf/io/orc.pyx +++ b/python/pylibcudf/pylibcudf/io/orc.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp cimport bool from libcpp.string cimport string @@ -8,6 +8,7 @@ from libcpp.vector cimport vector import datetime from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from pylibcudf.io.types cimport SourceInfo, TableWithMetadata, SinkInfo @@ -444,7 +445,7 @@ cdef class OrcReaderOptionsBuilder: cpdef TableWithMetadata read_orc( - OrcReaderOptions options, Stream stream = None, DeviceMemoryResource mr=None + OrcReaderOptions options, object stream = None, DeviceMemoryResource mr=None ): """ Read from ORC format. @@ -465,17 +466,17 @@ cpdef TableWithMetadata read_orc( """ cdef table_with_metadata c_result cdef Stream s = _get_stream(stream) + cdef cudaStream_t _cs = s.view().value() mr = _get_memory_resource(mr) - with nogil: - c_result = move(cpp_read_orc(options.c_obj, s.view(), mr.get_mr())) + c_result = move(cpp_read_orc(options.c_obj, _cs, mr.get_mr())) return TableWithMetadata.from_libcudf(c_result, s, mr) cpdef ParsedOrcStatistics read_parsed_orc_statistics( SourceInfo source_info, - Stream stream=None + object stream=None ): """ Read ORC statistics from a source. @@ -494,8 +495,9 @@ cpdef ParsedOrcStatistics read_parsed_orc_statistics( """ cdef Stream s = _get_stream(stream) cdef parsed_orc_statistics parsed + cdef cudaStream_t _cs = s.view().value() with nogil: - parsed = cpp_read_parsed_orc_statistics(source_info.c_obj, s.view()) + parsed = cpp_read_parsed_orc_statistics(source_info.c_obj, _cs) return ParsedOrcStatistics.from_libcudf(parsed) @@ -667,7 +669,7 @@ cdef class OrcWriterOptionsBuilder: return orc_options -cpdef void write_orc(OrcWriterOptions options, Stream stream = None): +cpdef void write_orc(OrcWriterOptions options, object stream = None): """ Write to ORC format. @@ -688,8 +690,9 @@ cpdef void write_orc(OrcWriterOptions options, Stream stream = None): None """ cdef Stream s = _get_stream(stream) + cdef cudaStream_t _cs = s.view().value() with nogil: - cpp_write_orc(move(options.c_obj), s.view()) + cpp_write_orc(move(options.c_obj), _cs) cdef class OrcChunkedWriter: @@ -721,7 +724,7 @@ cdef class OrcChunkedWriter: self.c_obj.get()[0].write(table.view()) @staticmethod - def from_options(ChunkedOrcWriterOptions options, Stream stream = None): + def from_options(ChunkedOrcWriterOptions options, object stream = None): """ Creates a chunked ORC writer from options @@ -740,7 +743,8 @@ cdef class OrcChunkedWriter: OrcChunkedWriter ) cdef Stream s = _get_stream(stream) - orc_writer.c_obj.reset(new orc_chunked_writer(options.c_obj, s.view())) + cdef cudaStream_t _cs = s.view().value() + orc_writer.c_obj.reset(new orc_chunked_writer(options.c_obj, _cs)) return orc_writer diff --git a/python/pylibcudf/pylibcudf/io/parquet.pxd b/python/pylibcudf/pylibcudf/io/parquet.pxd index d9350f77721..c98a90dd692 100644 --- a/python/pylibcudf/pylibcudf/io/parquet.pxd +++ b/python/pylibcudf/pylibcudf/io/parquet.pxd @@ -6,8 +6,8 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource +from rmm.pylibrmm.stream cimport Stream from pylibcudf.expressions cimport Expression @@ -74,7 +74,7 @@ cdef class ParquetReaderOptionsBuilder: cdef class ChunkedParquetReader: - cdef readonly Stream stream + cdef Stream _stream cdef DeviceMemoryResource mr cdef unique_ptr[cpp_chunked_parquet_reader] reader @@ -83,7 +83,7 @@ cdef class ChunkedParquetReader: cpdef read_parquet( - ParquetReaderOptions options, Stream stream = *, DeviceMemoryResource mr=* + ParquetReaderOptions options, object stream = *, DeviceMemoryResource mr=* ) @@ -180,7 +180,7 @@ cdef class ParquetWriterOptionsBuilder: cpdef ParquetWriterOptions build(self) -cpdef memoryview write_parquet(ParquetWriterOptions options, Stream stream = *) +cpdef memoryview write_parquet(ParquetWriterOptions options, object stream = *) cpdef bool is_supported_read_parquet(compression_type compression) diff --git a/python/pylibcudf/pylibcudf/io/parquet.pyi b/python/pylibcudf/pylibcudf/io/parquet.pyi index c0c31e22007..f0a092f63e0 100644 --- a/python/pylibcudf/pylibcudf/io/parquet.pyi +++ b/python/pylibcudf/pylibcudf/io/parquet.pyi @@ -5,7 +5,6 @@ from collections.abc import Mapping, Sequence from typing import Self from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.expressions import Expression from pylibcudf.io.types import ( @@ -20,6 +19,7 @@ from pylibcudf.io.types import ( ) from pylibcudf.table import Table from pylibcudf.types import TypeId +from pylibcudf.utils import CudaStreamLike class ParquetReaderOptions: def __init__(self): ... @@ -53,7 +53,7 @@ class ChunkedParquetReader: def __init__( self, options: ParquetReaderOptions, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, chunk_read_limit: int = 0, pass_read_limit: int = 1024000000, ) -> None: ... @@ -62,7 +62,7 @@ class ChunkedParquetReader: def read_parquet( options: ParquetReaderOptions, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> TableWithMetadata: ... @@ -101,7 +101,7 @@ class ParquetWriterOptionsBuilder: def build(self) -> ParquetWriterOptions: ... def write_parquet( - options: ParquetWriterOptions, stream: Stream | None = None + options: ParquetWriterOptions, stream: CudaStreamLike | None = None ) -> memoryview: ... def is_supported_read_parquet(compression: CompressionType) -> bool: ... def is_supported_write_parquet(compression: CompressionType) -> bool: ... @@ -112,7 +112,8 @@ class ChunkedParquetWriter: def write(self, table: Table, partitions_info: object = None) -> None: ... @staticmethod def from_options( - options: ChunkedParquetWriterOptions, stream: Stream | None = None + options: ChunkedParquetWriterOptions, + stream: CudaStreamLike | None = None, ) -> ChunkedParquetWriter: ... class ChunkedParquetWriterOptions: diff --git a/python/pylibcudf/pylibcudf/io/parquet.pyx b/python/pylibcudf/pylibcudf/io/parquet.pyx index c4bad082304..86904513cfa 100644 --- a/python/pylibcudf/pylibcudf/io/parquet.pyx +++ b/python/pylibcudf/pylibcudf/io/parquet.pyx @@ -46,6 +46,7 @@ from pylibcudf.libcudf.io.types cimport ( from pylibcudf.libcudf.types cimport size_type, type_id from pylibcudf.table cimport Table from pylibcudf.utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "ChunkedParquetReader", @@ -507,20 +508,21 @@ cdef class ChunkedParquetReader: def __init__( self, ParquetReaderOptions options, - Stream stream = None, + object stream = None, DeviceMemoryResource mr = None, size_t chunk_read_limit=0, size_t pass_read_limit=1024000000, ): - self.stream = _get_stream(stream) + self._stream = _get_stream(stream) self.mr = _get_memory_resource(mr) + cdef cudaStream_t stream_view = self._stream.view().value() with nogil: self.reader.reset( new cpp_chunked_parquet_reader( chunk_read_limit, pass_read_limit, options.c_obj, - self.stream.view(), + stream_view, self.mr.get_mr() ) ) @@ -560,11 +562,11 @@ cdef class ChunkedParquetReader: with nogil: c_result = move(self.reader.get()[0].read_chunk()) - return TableWithMetadata.from_libcudf(c_result, self.stream, mr) + return TableWithMetadata.from_libcudf(c_result, self._stream, mr) cpdef read_parquet( - ParquetReaderOptions options, Stream stream = None, DeviceMemoryResource mr=None + ParquetReaderOptions options, object stream = None, DeviceMemoryResource mr=None ): """ Read from Parquet format. @@ -584,9 +586,10 @@ cpdef read_parquet( Device memory resource used to allocate the returned table's device memory. """ cdef Stream s = _get_stream(stream) + cdef cudaStream_t _cs = s.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = move(cpp_read_parquet(options.c_obj, s.view(), mr.get_mr())) + c_result = move(cpp_read_parquet(options.c_obj, _cs, mr.get_mr())) return TableWithMetadata.from_libcudf(c_result, s, mr) @@ -640,7 +643,7 @@ cdef class ChunkedParquetWriter: self.c_obj.get()[0].write(table.view(), partitions) @staticmethod - def from_options(ChunkedParquetWriterOptions options, Stream stream = None): + def from_options(ChunkedParquetWriterOptions options, object stream = None): """ Creates a chunked Parquet writer from options @@ -659,8 +662,9 @@ cdef class ChunkedParquetWriter: ChunkedParquetWriter ) cdef Stream s = _get_stream(stream) + cdef cudaStream_t _cs = s.view().value() parquet_writer.c_obj.reset( - new cpp_chunked_parquet_writer(options.c_obj, s.view()) + new cpp_chunked_parquet_writer(options.c_obj, _cs) ) return parquet_writer @@ -1235,7 +1239,7 @@ cdef class ParquetWriterOptionsBuilder: return parquet_options -cpdef memoryview write_parquet(ParquetWriterOptions options, Stream stream = None): +cpdef memoryview write_parquet(ParquetWriterOptions options, object stream = None): """ Writes a set of columns to parquet format. @@ -1255,9 +1259,9 @@ cpdef memoryview write_parquet(ParquetWriterOptions options, Stream stream = Non """ cdef unique_ptr[vector[uint8_t]] c_result cdef Stream s = _get_stream(stream) - + cdef cudaStream_t _cs = s.view().value() with nogil: - c_result = cpp_write_parquet(move(options.c_obj), s.view()) + c_result = cpp_write_parquet(move(options.c_obj), _cs) return memoryview(HostBuffer.from_unique_ptr(move(c_result))) diff --git a/python/pylibcudf/pylibcudf/io/text.pxd b/python/pylibcudf/pylibcudf/io/text.pxd index 7623c8da26b..5276f9ffaba 100644 --- a/python/pylibcudf/pylibcudf/io/text.pxd +++ b/python/pylibcudf/pylibcudf/io/text.pxd @@ -1,10 +1,9 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr from libcpp.string cimport string from pylibcudf.column cimport Column -from pylibcudf.io.types cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from pylibcudf.libcudf.io.text cimport parse_options, data_chunk_source, byte_range_info @@ -23,7 +22,7 @@ cpdef Column multibyte_split( DataChunkSource source, str delimiter, ParseOptions options=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/io/text.pyi b/python/pylibcudf/pylibcudf/io/text.pyi index 66406c94dd2..581e45c3194 100644 --- a/python/pylibcudf/pylibcudf/io/text.pyi +++ b/python/pylibcudf/pylibcudf/io/text.pyi @@ -1,10 +1,10 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column +from pylibcudf.utils import CudaStreamLike class ByteRangeInfo: def __init__(self, offset: int, size: int) -> None: ... @@ -35,6 +35,6 @@ def multibyte_split( source: DataChunkSource, delimiter: str, options: ParseOptions | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/io/text.pyx b/python/pylibcudf/pylibcudf/io/text.pyx index 9fb220b0a37..be15701a4d8 100644 --- a/python/pylibcudf/pylibcudf/io/text.pyx +++ b/python/pylibcudf/pylibcudf/io/text.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from cython.operator cimport dereference @@ -9,10 +9,11 @@ from libcpp.utility cimport move from pylibcudf.column cimport Column from pylibcudf.utils cimport _get_stream, _get_memory_resource -from pylibcudf.io.types cimport Stream +from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.io cimport text as cpp_text +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "ByteRangeInfo", @@ -193,7 +194,7 @@ cpdef Column multibyte_split( DataChunkSource source, str delimiter, ParseOptions options=None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -224,7 +225,8 @@ cpdef Column multibyte_split( cdef unique_ptr[column] c_result cdef unique_ptr[data_chunk_source] c_source = move(source.c_source) cdef string c_delimiter = delimiter.encode() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if options is None: @@ -237,8 +239,8 @@ cpdef Column multibyte_split( dereference(c_source), c_delimiter, c_options, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/io/timezone.pxd b/python/pylibcudf/pylibcudf/io/timezone.pxd index a2fa33d102d..9a12be928b2 100644 --- a/python/pylibcudf/pylibcudf/io/timezone.pxd +++ b/python/pylibcudf/pylibcudf/io/timezone.pxd @@ -1,11 +1,11 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from ..table cimport Table -from .types cimport Stream + from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource cpdef Table make_timezone_transition_table( - str tzif_dir, str timezone_name, Stream stream=*, DeviceMemoryResource mr=* + str tzif_dir, str timezone_name, object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/io/timezone.pyi b/python/pylibcudf/pylibcudf/io/timezone.pyi index d83f68424b4..f87dda70f70 100644 --- a/python/pylibcudf/pylibcudf/io/timezone.pyi +++ b/python/pylibcudf/pylibcudf/io/timezone.pyi @@ -1,14 +1,14 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.table import Table +from pylibcudf.utils import CudaStreamLike def make_timezone_transition_table( tzif_dir: str, timezone_name: str, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... diff --git a/python/pylibcudf/pylibcudf/io/timezone.pyx b/python/pylibcudf/pylibcudf/io/timezone.pyx index 0416df1cf0b..033ed15a1ba 100644 --- a/python/pylibcudf/pylibcudf/io/timezone.pyx +++ b/python/pylibcudf/pylibcudf/io/timezone.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -12,13 +12,14 @@ from pylibcudf.libcudf.table.table cimport table from ..utils cimport _get_stream, _get_memory_resource from ..table cimport Table -from .types cimport Stream +from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["make_timezone_transition_table"] cpdef Table make_timezone_transition_table( - str tzif_dir, str timezone_name, Stream stream=None, DeviceMemoryResource mr=None, + str tzif_dir, str timezone_name, object stream=None, DeviceMemoryResource mr=None, ): """ Creates a transition table to convert ORC timestamps to UTC. @@ -42,15 +43,16 @@ cpdef Table make_timezone_transition_table( cdef unique_ptr[table] c_result cdef string c_tzdir = tzif_dir.encode() cdef string c_tzname = timezone_name.encode() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_make_timezone_transition_table( make_optional[string](c_tzdir), c_tzname, - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/io/types.pxd b/python/pylibcudf/pylibcudf/io/types.pxd index db7e2ad95c5..1e52f4faa05 100644 --- a/python/pylibcudf/pylibcudf/io/types.pxd +++ b/python/pylibcudf/pylibcudf/io/types.pxd @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libc.stdint cimport uint8_t, int32_t @@ -29,7 +29,6 @@ from pylibcudf.libcudf.utilities.span cimport host_span from pylibcudf.table cimport Table -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource cdef class PartitionInfo: @@ -86,7 +85,7 @@ cdef class TableWithMetadata: @staticmethod cdef TableWithMetadata from_libcudf( - table_with_metadata& tbl, Stream stream, DeviceMemoryResource mr + table_with_metadata& tbl, object stream, DeviceMemoryResource mr ) cdef class SourceInfo: diff --git a/python/pylibcudf/pylibcudf/io/types.pyx b/python/pylibcudf/pylibcudf/io/types.pyx index 1c4a7f49268..27c3bb47caf 100644 --- a/python/pylibcudf/pylibcudf/io/types.pyx +++ b/python/pylibcudf/pylibcudf/io/types.pyx @@ -33,7 +33,6 @@ from pylibcudf.libcudf.utilities.span cimport device_span, host_span from pylibcudf.span import is_span from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream import codecs import errno @@ -396,7 +395,7 @@ cdef class TableWithMetadata: @staticmethod cdef TableWithMetadata from_libcudf( table_with_metadata& tbl_with_meta, - Stream stream, + object stream, DeviceMemoryResource mr ): """Create a Python TableWithMetadata from a libcudf table_with_metadata""" diff --git a/python/pylibcudf/pylibcudf/join.pxd b/python/pylibcudf/pylibcudf/join.pxd index 31a998029e3..f0b69a42621 100644 --- a/python/pylibcudf/pylibcudf/join.pxd +++ b/python/pylibcudf/pylibcudf/join.pxd @@ -1,10 +1,9 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr from pylibcudf.libcudf cimport join as cpp_join from pylibcudf.libcudf.types cimport null_equality -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from .column cimport Column @@ -16,7 +15,7 @@ cpdef tuple inner_join( Table left_keys, Table right_keys, null_equality nulls_equal, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -24,7 +23,7 @@ cpdef tuple left_join( Table left_keys, Table right_keys, null_equality nulls_equal, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -32,7 +31,7 @@ cpdef tuple full_join( Table left_keys, Table right_keys, null_equality nulls_equal, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -40,7 +39,7 @@ cpdef Column left_semi_join( Table left_keys, Table right_keys, null_equality nulls_equal, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -48,19 +47,19 @@ cpdef Column left_anti_join( Table left_keys, Table right_keys, null_equality nulls_equal, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef Table cross_join( - Table left, Table right, Stream stream=*, DeviceMemoryResource mr=* + Table left, Table right, object stream = *, DeviceMemoryResource mr=* ) cpdef tuple conditional_inner_join( Table left, Table right, Expression binary_predicate, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -68,7 +67,7 @@ cpdef tuple conditional_left_join( Table left, Table right, Expression binary_predicate, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -76,7 +75,7 @@ cpdef tuple conditional_full_join( Table left, Table right, Expression binary_predicate, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -84,7 +83,7 @@ cpdef Column conditional_left_semi_join( Table left, Table right, Expression binary_predicate, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -92,7 +91,7 @@ cpdef Column conditional_left_anti_join( Table left, Table right, Expression binary_predicate, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -103,7 +102,7 @@ cpdef tuple mixed_inner_join( Table right_conditional, Expression binary_predicate, null_equality nulls_equal, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -114,7 +113,7 @@ cpdef tuple mixed_left_join( Table right_conditional, Expression binary_predicate, null_equality nulls_equal, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -125,7 +124,7 @@ cpdef tuple mixed_full_join( Table right_conditional, Expression binary_predicate, null_equality nulls_equal, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -136,7 +135,7 @@ cpdef Column mixed_left_semi_join( Table right_conditional, Expression binary_predicate, null_equality nulls_equal, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -147,7 +146,7 @@ cpdef Column mixed_left_anti_join( Table right_conditional, Expression binary_predicate, null_equality nulls_equal, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) diff --git a/python/pylibcudf/pylibcudf/join.pyi b/python/pylibcudf/pylibcudf/join.pyi index 615eb914618..1cf86c7c704 100644 --- a/python/pylibcudf/pylibcudf/join.pyi +++ b/python/pylibcudf/pylibcudf/join.pyi @@ -4,12 +4,12 @@ from enum import IntEnum from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.expressions import Expression from pylibcudf.table import Table from pylibcudf.types import NullEquality +from pylibcudf.utils import CudaStreamLike class SetAsBuildTable(IntEnum): LEFT = ... @@ -19,76 +19,76 @@ def inner_join( left_keys: Table, right_keys: Table, nulls_equal: NullEquality, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[Column, Column]: ... def left_join( left_keys: Table, right_keys: Table, nulls_equal: NullEquality, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[Column, Column]: ... def full_join( left_keys: Table, right_keys: Table, nulls_equal: NullEquality, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[Column, Column]: ... def left_semi_join( left_keys: Table, right_keys: Table, nulls_equal: NullEquality, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def left_anti_join( left_keys: Table, right_keys: Table, nulls_equal: NullEquality, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def cross_join( left: Table, right: Table, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def conditional_inner_join( left: Table, right: Table, binary_predicate: Expression, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[Column, Column]: ... def conditional_left_join( left: Table, right: Table, binary_predicate: Expression, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[Column, Column]: ... def conditional_full_join( left: Table, right: Table, binary_predicate: Expression, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[Column, Column]: ... def conditional_left_semi_join( left: Table, right: Table, binary_predicate: Expression, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def conditional_left_anti_join( left: Table, right: Table, binary_predicate: Expression, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def mixed_inner_join( @@ -98,7 +98,7 @@ def mixed_inner_join( right_conditional: Table, binary_predicate: Expression, nulls_equal: NullEquality, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[Column, Column]: ... def mixed_left_join( @@ -108,7 +108,7 @@ def mixed_left_join( right_conditional: Table, binary_predicate: Expression, nulls_equal: NullEquality, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[Column, Column]: ... def mixed_full_join( @@ -118,7 +118,7 @@ def mixed_full_join( right_conditional: Table, binary_predicate: Expression, nulls_equal: NullEquality, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[Column, Column]: ... def mixed_left_semi_join( @@ -128,7 +128,7 @@ def mixed_left_semi_join( right_conditional: Table, binary_predicate: Expression, nulls_equal: NullEquality, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def mixed_left_anti_join( @@ -138,7 +138,7 @@ def mixed_left_anti_join( right_conditional: Table, binary_predicate: Expression, nulls_equal: NullEquality, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... @@ -148,17 +148,17 @@ class FilteredJoin: build: Table, compare_nulls: NullEquality, load_factor: float = ..., - stream: Stream | None = None, + stream: CudaStreamLike | None = None, ) -> None: ... def semi_join( self, probe: Table, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def anti_join( self, probe: Table, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/join.pyx b/python/pylibcudf/pylibcudf/join.pyx index 61a321b27a8..78a44554dff 100644 --- a/python/pylibcudf/pylibcudf/join.pyx +++ b/python/pylibcudf/pylibcudf/join.pyx @@ -22,6 +22,7 @@ from .table cimport Table from .utils cimport _get_stream, _get_memory_resource from pylibcudf.libcudf.join import set_as_build_table as SetAsBuildTable # no-cython-lint # noqa: F401, deprecated +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "conditional_full_join", @@ -45,9 +46,10 @@ __all__ = [ ] cdef Column _column_from_gather_map( - cpp_join.gather_map_type gather_map, Stream stream, DeviceMemoryResource mr + cpp_join.gather_map_type gather_map, object stream, DeviceMemoryResource mr ): # helper to convert a gather map to a Column + cdef Stream _stream = _get_stream(stream) return Column.from_libcudf( move( make_unique[column]( @@ -55,9 +57,7 @@ cdef Column _column_from_gather_map( device_buffer(), 0 ) - ), - stream, - mr + ), _stream, mr ) @@ -65,7 +65,7 @@ cpdef tuple inner_join( Table left_keys, Table right_keys, null_equality nulls_equal, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Perform an inner join between two tables. @@ -89,16 +89,21 @@ cpdef tuple inner_join( """ cdef cpp_join.gather_map_pair_type c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_join.inner_join( - left_keys.view(), right_keys.view(), nulls_equal, stream.view(), mr.get_mr() + left_keys.view(), + right_keys.view(), + nulls_equal, + _cs, + mr.get_mr() ) return ( - _column_from_gather_map(move(c_result.first), stream, mr), - _column_from_gather_map(move(c_result.second), stream, mr), + _column_from_gather_map(move(c_result.first), _stream, mr), + _column_from_gather_map(move(c_result.second), _stream, mr), ) @@ -106,7 +111,7 @@ cpdef tuple left_join( Table left_keys, Table right_keys, null_equality nulls_equal, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Perform a left join between two tables. @@ -130,16 +135,21 @@ cpdef tuple left_join( """ cdef cpp_join.gather_map_pair_type c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_join.left_join( - left_keys.view(), right_keys.view(), nulls_equal, stream.view(), mr.get_mr() + left_keys.view(), + right_keys.view(), + nulls_equal, + _cs, + mr.get_mr() ) return ( - _column_from_gather_map(move(c_result.first), stream, mr), - _column_from_gather_map(move(c_result.second), stream, mr), + _column_from_gather_map(move(c_result.first), _stream, mr), + _column_from_gather_map(move(c_result.second), _stream, mr), ) @@ -147,7 +157,7 @@ cpdef tuple full_join( Table left_keys, Table right_keys, null_equality nulls_equal, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Perform a full join between two tables. @@ -171,16 +181,21 @@ cpdef tuple full_join( """ cdef cpp_join.gather_map_pair_type c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_join.full_join( - left_keys.view(), right_keys.view(), nulls_equal, stream.view(), mr.get_mr() + left_keys.view(), + right_keys.view(), + nulls_equal, + _cs, + mr.get_mr() ) return ( - _column_from_gather_map(move(c_result.first), stream, mr), - _column_from_gather_map(move(c_result.second), stream, mr), + _column_from_gather_map(move(c_result.first), _stream, mr), + _column_from_gather_map(move(c_result.second), _stream, mr), ) @@ -188,7 +203,7 @@ cpdef Column left_semi_join( Table left_keys, Table right_keys, null_equality nulls_equal, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Perform a left semi join between two tables. @@ -211,7 +226,8 @@ cpdef Column left_semi_join( """ cdef cpp_join.gather_map_type c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) cdef unique_ptr[cpp_join.filtered_join] join_obj @@ -221,22 +237,22 @@ cpdef Column left_semi_join( new cpp_join.filtered_join( right_keys.view(), nulls_equal, - stream.view() + _cs ) ) c_result = join_obj.get()[0].semi_join( left_keys.view(), - stream.view(), + _cs, mr.get_mr() ) - return _column_from_gather_map(move(c_result), stream, mr) + return _column_from_gather_map(move(c_result), _stream, mr) cpdef Column left_anti_join( Table left_keys, Table right_keys, null_equality nulls_equal, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Perform a left anti join between two tables. @@ -259,7 +275,8 @@ cpdef Column left_anti_join( """ cdef cpp_join.gather_map_type c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) cdef unique_ptr[cpp_join.filtered_join] join_obj @@ -269,19 +286,19 @@ cpdef Column left_anti_join( new cpp_join.filtered_join( right_keys.view(), nulls_equal, - stream.view() + _cs ) ) c_result = join_obj.get()[0].anti_join( left_keys.view(), - stream.view(), + _cs, mr.get_mr() ) - return _column_from_gather_map(move(c_result), stream, mr) + return _column_from_gather_map(move(c_result), _stream, mr) cpdef Table cross_join( - Table left, Table right, Stream stream=None, DeviceMemoryResource mr=None + Table left, Table right, object stream=None, DeviceMemoryResource mr=None ): """Perform a cross join on two tables. @@ -305,21 +322,22 @@ cpdef Table cross_join( """ cdef unique_ptr[table] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: result = cpp_join.cross_join( - left.view(), right.view(), stream.view(), mr.get_mr() + left.view(), right.view(), _cs, mr.get_mr() ) - return Table.from_libcudf(move(result), stream, mr) + return Table.from_libcudf(move(result), _stream, mr) cpdef tuple conditional_inner_join( Table left, Table right, Expression binary_predicate, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Perform a conditional inner join between two tables. @@ -344,7 +362,8 @@ cpdef tuple conditional_inner_join( cdef cpp_join.gather_map_pair_type c_result cdef optional[size_t] output_size - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -353,12 +372,12 @@ cpdef tuple conditional_inner_join( right.view(), dereference(binary_predicate.c_obj.get()), output_size, - stream.view(), + _cs, mr.get_mr() ) return ( - _column_from_gather_map(move(c_result.first), stream, mr), - _column_from_gather_map(move(c_result.second), stream, mr), + _column_from_gather_map(move(c_result.first), _stream, mr), + _column_from_gather_map(move(c_result.second), _stream, mr), ) @@ -366,7 +385,7 @@ cpdef tuple conditional_left_join( Table left, Table right, Expression binary_predicate, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Perform a conditional left join between two tables. @@ -391,7 +410,8 @@ cpdef tuple conditional_left_join( cdef cpp_join.gather_map_pair_type c_result cdef optional[size_t] output_size - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -400,12 +420,12 @@ cpdef tuple conditional_left_join( right.view(), dereference(binary_predicate.c_obj.get()), output_size, - stream.view(), + _cs, mr.get_mr() ) return ( - _column_from_gather_map(move(c_result.first), stream, mr), - _column_from_gather_map(move(c_result.second), stream, mr), + _column_from_gather_map(move(c_result.first), _stream, mr), + _column_from_gather_map(move(c_result.second), _stream, mr), ) @@ -413,7 +433,7 @@ cpdef tuple conditional_full_join( Table left, Table right, Expression binary_predicate, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Perform a conditional full join between two tables. @@ -437,7 +457,8 @@ cpdef tuple conditional_full_join( """ cdef cpp_join.gather_map_pair_type c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -445,12 +466,12 @@ cpdef tuple conditional_full_join( left.view(), right.view(), dereference(binary_predicate.c_obj.get()), - stream.view(), + _cs, mr.get_mr() ) return ( - _column_from_gather_map(move(c_result.first), stream, mr), - _column_from_gather_map(move(c_result.second), stream, mr), + _column_from_gather_map(move(c_result.first), _stream, mr), + _column_from_gather_map(move(c_result.second), _stream, mr), ) @@ -458,7 +479,7 @@ cpdef Column conditional_left_semi_join( Table left, Table right, Expression binary_predicate, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Perform a conditional left semi join between two tables. @@ -482,7 +503,8 @@ cpdef Column conditional_left_semi_join( cdef cpp_join.gather_map_type c_result cdef optional[size_t] output_size - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -491,17 +513,17 @@ cpdef Column conditional_left_semi_join( right.view(), dereference(binary_predicate.c_obj.get()), output_size, - stream.view(), + _cs, mr.get_mr() ) - return _column_from_gather_map(move(c_result), stream, mr) + return _column_from_gather_map(move(c_result), _stream, mr) cpdef Column conditional_left_anti_join( Table left, Table right, Expression binary_predicate, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Perform a conditional left anti join between two tables. @@ -525,7 +547,8 @@ cpdef Column conditional_left_anti_join( cdef cpp_join.gather_map_type c_result cdef optional[size_t] output_size - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -534,10 +557,10 @@ cpdef Column conditional_left_anti_join( right.view(), dereference(binary_predicate.c_obj.get()), output_size, - stream.view(), + _cs, mr.get_mr() ) - return _column_from_gather_map(move(c_result), stream, mr) + return _column_from_gather_map(move(c_result), _stream, mr) cpdef tuple mixed_inner_join( @@ -547,7 +570,7 @@ cpdef tuple mixed_inner_join( Table right_conditional, Expression binary_predicate, null_equality nulls_equal, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Perform a mixed inner join between two tables. @@ -578,7 +601,8 @@ cpdef tuple mixed_inner_join( cdef cpp_join.gather_map_pair_type c_result cdef cpp_join.output_size_data_type empty_optional - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -590,12 +614,12 @@ cpdef tuple mixed_inner_join( dereference(binary_predicate.c_obj.get()), nulls_equal, empty_optional, - stream.view(), + _cs, mr.get_mr() ) return ( - _column_from_gather_map(move(c_result.first), stream, mr), - _column_from_gather_map(move(c_result.second), stream, mr), + _column_from_gather_map(move(c_result.first), _stream, mr), + _column_from_gather_map(move(c_result.second), _stream, mr), ) @@ -606,7 +630,7 @@ cpdef tuple mixed_left_join( Table right_conditional, Expression binary_predicate, null_equality nulls_equal, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Perform a mixed left join between two tables. @@ -637,7 +661,8 @@ cpdef tuple mixed_left_join( cdef cpp_join.gather_map_pair_type c_result cdef cpp_join.output_size_data_type empty_optional - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -649,12 +674,12 @@ cpdef tuple mixed_left_join( dereference(binary_predicate.c_obj.get()), nulls_equal, empty_optional, - stream.view(), + _cs, mr.get_mr() ) return ( - _column_from_gather_map(move(c_result.first), stream, mr), - _column_from_gather_map(move(c_result.second), stream, mr), + _column_from_gather_map(move(c_result.first), _stream, mr), + _column_from_gather_map(move(c_result.second), _stream, mr), ) @@ -665,7 +690,7 @@ cpdef tuple mixed_full_join( Table right_conditional, Expression binary_predicate, null_equality nulls_equal, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Perform a mixed full join between two tables. @@ -696,7 +721,8 @@ cpdef tuple mixed_full_join( cdef cpp_join.gather_map_pair_type c_result cdef cpp_join.output_size_data_type empty_optional - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -708,12 +734,12 @@ cpdef tuple mixed_full_join( dereference(binary_predicate.c_obj.get()), nulls_equal, empty_optional, - stream.view(), + _cs, mr.get_mr() ) return ( - _column_from_gather_map(move(c_result.first), stream, mr), - _column_from_gather_map(move(c_result.second), stream, mr), + _column_from_gather_map(move(c_result.first), _stream, mr), + _column_from_gather_map(move(c_result.second), _stream, mr), ) @@ -724,7 +750,7 @@ cpdef Column mixed_left_semi_join( Table right_conditional, Expression binary_predicate, null_equality nulls_equal, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Perform a mixed left semi join between two tables. @@ -753,7 +779,8 @@ cpdef Column mixed_left_semi_join( """ cdef cpp_join.gather_map_type c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -764,10 +791,10 @@ cpdef Column mixed_left_semi_join( right_conditional.view(), dereference(binary_predicate.c_obj.get()), nulls_equal, - stream.view(), + _cs, mr.get_mr() ) - return _column_from_gather_map(move(c_result), stream, mr) + return _column_from_gather_map(move(c_result), _stream, mr) cpdef Column mixed_left_anti_join( @@ -777,7 +804,7 @@ cpdef Column mixed_left_anti_join( Table right_conditional, Expression binary_predicate, null_equality nulls_equal, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Perform a mixed left anti join between two tables. @@ -806,7 +833,8 @@ cpdef Column mixed_left_anti_join( """ cdef cpp_join.gather_map_type c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -817,10 +845,10 @@ cpdef Column mixed_left_anti_join( right_conditional.view(), dereference(binary_predicate.c_obj.get()), nulls_equal, - stream.view(), + _cs, mr.get_mr() ) - return _column_from_gather_map(move(c_result), stream, mr) + return _column_from_gather_map(move(c_result), _stream, mr) cdef class FilteredJoin: @@ -841,7 +869,7 @@ cdef class FilteredJoin: Table build, null_equality compare_nulls, double load_factor=0.5, - Stream stream=None, + object stream=None, ): """ Construct a filtered hash join object for subsequent probe calls. @@ -858,7 +886,8 @@ cdef class FilteredJoin: stream : Stream, optional CUDA stream used for device memory operations and kernel launches. """ - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() with nogil: self.c_obj.reset( @@ -866,14 +895,14 @@ cdef class FilteredJoin: build.view(), compare_nulls, load_factor, - stream.view() + _cs ) ) def semi_join( self, Table probe, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -898,21 +927,22 @@ cdef class FilteredJoin: """ cdef cpp_join.gather_map_type c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = self.c_obj.get()[0].semi_join( probe.view(), - stream.view(), + _cs, mr.get_mr() ) - return _column_from_gather_map(move(c_result), stream, mr) + return _column_from_gather_map(move(c_result), _stream, mr) def anti_join( self, Table probe, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -937,13 +967,14 @@ cdef class FilteredJoin: """ cdef cpp_join.gather_map_type c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = self.c_obj.get()[0].anti_join( probe.view(), - stream.view(), + _cs, mr.get_mr() ) - return _column_from_gather_map(move(c_result), stream, mr) + return _column_from_gather_map(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/json.pxd b/python/pylibcudf/pylibcudf/json.pxd index 5489fa26ee8..47cf3b37c63 100644 --- a/python/pylibcudf/pylibcudf/json.pxd +++ b/python/pylibcudf/pylibcudf/json.pxd @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column @@ -6,7 +6,6 @@ from pylibcudf.libcudf.json cimport get_json_object_options from pylibcudf.scalar cimport Scalar from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cdef class GetJsonObjectOptions: @@ -17,6 +16,6 @@ cpdef Column get_json_object( Column col, Scalar json_path, GetJsonObjectOptions options=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) diff --git a/python/pylibcudf/pylibcudf/json.pyi b/python/pylibcudf/pylibcudf/json.pyi index fa6bb08d510..a60bcb36f26 100644 --- a/python/pylibcudf/pylibcudf/json.pyi +++ b/python/pylibcudf/pylibcudf/json.pyi @@ -1,11 +1,11 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar +from pylibcudf.utils import CudaStreamLike class GetJsonObjectOptions: def __init__( @@ -26,6 +26,6 @@ def get_json_object( col: Column, json_path: Scalar, options: GetJsonObjectOptions | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/json.pyx b/python/pylibcudf/pylibcudf/json.pyx index b50bd4e7714..a470f6a1cb3 100644 --- a/python/pylibcudf/pylibcudf/json.pyx +++ b/python/pylibcudf/pylibcudf/json.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from cython.operator cimport dereference @@ -15,6 +15,7 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["GetJsonObjectOptions", "get_json_object"] @@ -120,7 +121,7 @@ cpdef Column get_json_object( Column col, Scalar json_path, GetJsonObjectOptions options=None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -155,7 +156,8 @@ cpdef Column get_json_object( options = GetJsonObjectOptions() cdef cpp_json.get_json_object_options c_options = options.options - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -163,8 +165,8 @@ cpdef Column get_json_object( col.view(), dereference(c_json_path), c_options, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/labeling.pxd b/python/pylibcudf/pylibcudf/labeling.pxd index fc93568ed7c..0d8f02d48ce 100644 --- a/python/pylibcudf/pylibcudf/labeling.pxd +++ b/python/pylibcudf/pylibcudf/labeling.pxd @@ -1,11 +1,10 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp cimport bool from pylibcudf.libcudf.labeling cimport inclusive from .column cimport Column -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource @@ -15,6 +14,6 @@ cpdef Column label_bins( inclusive left_inclusive, Column right_edges, inclusive right_inclusive, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/labeling.pyi b/python/pylibcudf/pylibcudf/labeling.pyi index e9ff5c97f0b..272edd43f5f 100644 --- a/python/pylibcudf/pylibcudf/labeling.pyi +++ b/python/pylibcudf/pylibcudf/labeling.pyi @@ -1,12 +1,12 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from enum import IntEnum from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column +from pylibcudf.utils import CudaStreamLike class Inclusive(IntEnum): YES = ... @@ -18,6 +18,6 @@ def label_bins( left_inclusive: Inclusive, right_edges: Column, right_inclusive: Inclusive, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/labeling.pyx b/python/pylibcudf/pylibcudf/labeling.pyx index 878390543cb..e3a052f7cb8 100644 --- a/python/pylibcudf/pylibcudf/labeling.pyx +++ b/python/pylibcudf/pylibcudf/labeling.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -14,6 +14,7 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from .column cimport Column from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["Inclusive", "label_bins"] @@ -23,7 +24,7 @@ cpdef Column label_bins( inclusive left_inclusive, Column right_edges, inclusive right_inclusive, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Labels elements based on membership in the specified bins. @@ -54,7 +55,8 @@ cpdef Column label_bins( according to the specified bins. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -64,10 +66,10 @@ cpdef Column label_bins( left_inclusive, right_edges.view(), right_inclusive, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) Inclusive.__str__ = Inclusive.__repr__ diff --git a/python/pylibcudf/pylibcudf/libcudf/binaryop.pxd b/python/pylibcudf/pylibcudf/libcudf/binaryop.pxd index 7ec2c6fe31f..303b112f71e 100644 --- a/python/pylibcudf/pylibcudf/libcudf/binaryop.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/binaryop.pxd @@ -10,7 +10,7 @@ from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport scalar from pylibcudf.libcudf.types cimport data_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -57,7 +57,7 @@ cdef extern from "cudf/binaryop.hpp" namespace "cudf" nogil: const column_view& rhs, binary_operator op, data_type output_type, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -66,7 +66,7 @@ cdef extern from "cudf/binaryop.hpp" namespace "cudf" nogil: const scalar& rhs, binary_operator op, data_type output_type, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -75,7 +75,7 @@ cdef extern from "cudf/binaryop.hpp" namespace "cudf" nogil: const column_view& rhs, binary_operator op, data_type output_type, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -84,7 +84,7 @@ cdef extern from "cudf/binaryop.hpp" namespace "cudf" nogil: const column_view& rhs, const string& op, data_type output_type, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/column/column.pxd b/python/pylibcudf/pylibcudf/libcudf/column/column.pxd index daefd24fb7b..b22eeb1dd40 100644 --- a/python/pylibcudf/pylibcudf/libcudf/column/column.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/column/column.pxd @@ -11,7 +11,7 @@ from pylibcudf.libcudf.column.column_view cimport ( from pylibcudf.libcudf.types cimport data_type, size_type from rmm.librmm.device_buffer cimport device_buffer -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -25,13 +25,13 @@ cdef extern from "cudf/column/column.hpp" namespace "cudf" nogil: column() except +libcudf_exception_handler column( const column& other, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler column( column_view view, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/column/column_factories.pxd b/python/pylibcudf/pylibcudf/libcudf/column/column_factories.pxd index 5e17d3b89bd..f8cf3b38ccb 100644 --- a/python/pylibcudf/pylibcudf/libcudf/column/column_factories.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/column/column_factories.pxd @@ -13,7 +13,7 @@ from pylibcudf.libcudf.types cimport ( ) from rmm.librmm.device_buffer cimport device_buffer -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -22,7 +22,7 @@ cdef extern from "cudf/column/column_factories.hpp" namespace "cudf" nogil: data_type type, size_type size, mask_state state, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -31,7 +31,7 @@ cdef extern from "cudf/column/column_factories.hpp" namespace "cudf" nogil: size_type size, device_buffer mask, size_type null_count, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -39,7 +39,7 @@ cdef extern from "cudf/column/column_factories.hpp" namespace "cudf" nogil: data_type type, size_type size, mask_state state, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] make_fixed_point_column( @@ -47,14 +47,14 @@ cdef extern from "cudf/column/column_factories.hpp" namespace "cudf" nogil: size_type size, device_buffer mask, size_type null_count, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] make_timestamp_column( data_type type, size_type size, mask_state state, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] make_timestamp_column( @@ -62,14 +62,14 @@ cdef extern from "cudf/column/column_factories.hpp" namespace "cudf" nogil: size_type size, device_buffer mask, size_type null_count, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] make_duration_column( data_type type, size_type size, mask_state state, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] make_duration_column( @@ -77,14 +77,14 @@ cdef extern from "cudf/column/column_factories.hpp" namespace "cudf" nogil: size_type size, device_buffer mask, size_type null_count, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] make_fixed_width_column( data_type type, size_type size, mask_state state, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] make_fixed_width_column( @@ -92,27 +92,27 @@ cdef extern from "cudf/column/column_factories.hpp" namespace "cudf" nogil: size_type size, device_buffer mask, size_type null_count, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] make_column_from_scalar( const scalar& s, size_type size, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] make_dictionary_from_scalar( const scalar& s, size_type size, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] make_dictionary_column( unique_ptr[column] keys_column, unique_ptr[column] indices_column, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] make_empty_column( diff --git a/python/pylibcudf/pylibcudf/libcudf/concatenate.pxd b/python/pylibcudf/pylibcudf/libcudf/concatenate.pxd index 272f452a0a0..53cadee79c9 100644 --- a/python/pylibcudf/pylibcudf/libcudf/concatenate.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/concatenate.pxd @@ -8,7 +8,7 @@ from pylibcudf.libcudf.table.table cimport table, table_view from pylibcudf.libcudf.utilities.span cimport host_span from rmm.librmm.device_buffer cimport device_buffer -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -24,11 +24,11 @@ cdef extern from "cudf/concatenate.hpp" namespace "cudf" nogil: cdef unique_ptr[column] concatenate( const vector[column_view] columns, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[table] concatenate( const vector[table_view] tables, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/contiguous_split.pxd b/python/pylibcudf/pylibcudf/libcudf/contiguous_split.pxd index 9d839835465..dd439d0d01d 100644 --- a/python/pylibcudf/pylibcudf/libcudf/contiguous_split.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/contiguous_split.pxd @@ -10,7 +10,7 @@ from pylibcudf.libcudf.table.table_view cimport table_view from pylibcudf.libcudf.types cimport size_type from pylibcudf.libcudf.utilities.span cimport device_span from rmm.librmm.device_buffer cimport device_buffer -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -32,7 +32,7 @@ cdef extern from "cudf/contiguous_split.hpp" namespace "cudf" nogil: unique_ptr[chunked_pack] create( const table_view & input, size_t user_buffer_size, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref temp_mr, ) except +libcudf_exception_handler @@ -43,13 +43,13 @@ cdef extern from "cudf/contiguous_split.hpp" namespace "cudf" nogil: cdef vector[contiguous_split_result] contiguous_split ( table_view input_table, vector[size_type] splits, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef packed_columns pack ( const table_view& input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/copying.pxd b/python/pylibcudf/pylibcudf/libcudf/copying.pxd index 2c3741342e9..36c95fa777c 100644 --- a/python/pylibcudf/pylibcudf/libcudf/copying.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/copying.pxd @@ -17,7 +17,7 @@ from pylibcudf.libcudf.table.table_view cimport table_view from pylibcudf.libcudf.types cimport size_type from rmm.librmm.device_buffer cimport device_buffer -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref ctypedef const scalar constscalar @@ -31,7 +31,7 @@ cdef extern from "cudf/copying.hpp" namespace "cudf" nogil: const table_view& source_table, const column_view& gather_map, out_of_bounds_policy policy, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -39,7 +39,7 @@ cdef extern from "cudf/copying.hpp" namespace "cudf" nogil: const column_view& input, size_type offset, const scalar& fill_values, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -47,7 +47,7 @@ cdef extern from "cudf/copying.hpp" namespace "cudf" nogil: const table_view& source_table, const column_view& scatter_map, const table_view& target_table, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -55,7 +55,7 @@ cdef extern from "cudf/copying.hpp" namespace "cudf" nogil: const vector[reference_wrapper[constscalar]]& source_scalars, const column_view& indices, const table_view& target, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -71,7 +71,7 @@ cdef extern from "cudf/copying.hpp" namespace "cudf" nogil: cdef unique_ptr[column] allocate_like ( const column_view& input_column, mask_allocation_policy policy, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -79,7 +79,7 @@ cdef extern from "cudf/copying.hpp" namespace "cudf" nogil: const column_view& input_column, size_type size, mask_allocation_policy policy, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -93,7 +93,7 @@ cdef extern from "cudf/copying.hpp" namespace "cudf" nogil: size_type input_begin, size_type input_end, size_type target_begin, - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler cdef unique_ptr[column] copy_range ( @@ -102,39 +102,39 @@ cdef extern from "cudf/copying.hpp" namespace "cudf" nogil: size_type input_begin, size_type input_end, size_type target_begin, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef vector[column_view] slice ( const column_view& input_column, vector[size_type] indices, - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler cdef vector[table_view] slice ( const table_view& input_table, vector[size_type] indices, - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler cdef vector[column_view] split ( const column_view& input_column, vector[size_type] splits, - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler cdef vector[table_view] split ( const table_view& input_table, vector[size_type] splits, - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler cdef unique_ptr[column] copy_if_else ( const column_view& lhs, const column_view& rhs, const column_view& boolean_mask, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -142,7 +142,7 @@ cdef extern from "cudf/copying.hpp" namespace "cudf" nogil: const scalar& lhs, const column_view& rhs, const column_view& boolean_mask, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -150,7 +150,7 @@ cdef extern from "cudf/copying.hpp" namespace "cudf" nogil: const column_view& lhs, const scalar& rhs, const column_view boolean_mask, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -158,7 +158,7 @@ cdef extern from "cudf/copying.hpp" namespace "cudf" nogil: const scalar& lhs, const scalar& rhs, const column_view boolean_mask, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -166,7 +166,7 @@ cdef extern from "cudf/copying.hpp" namespace "cudf" nogil: const table_view& input, const table_view& target, const column_view& boolean_mask, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -174,14 +174,14 @@ cdef extern from "cudf/copying.hpp" namespace "cudf" nogil: const vector[reference_wrapper[constscalar]]& input, const table_view& target, const column_view& boolean_mask, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[scalar] get_element ( const column_view& input, size_type index, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/datetime.pxd b/python/pylibcudf/pylibcudf/libcudf/datetime.pxd index a14932f8910..7db66dc1070 100644 --- a/python/pylibcudf/pylibcudf/libcudf/datetime.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/datetime.pxd @@ -7,7 +7,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport scalar -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -27,7 +27,7 @@ cdef extern from "cudf/datetime.hpp" namespace "cudf::datetime" nogil: cdef unique_ptr[column] extract_datetime_component( const column_view& column, datetime_component component, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -42,54 +42,54 @@ cdef extern from "cudf/datetime.hpp" namespace "cudf::datetime" nogil: cdef unique_ptr[column] ceil_datetimes( const column_view& column, rounding_frequency freq, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] floor_datetimes( const column_view& column, rounding_frequency freq, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] round_datetimes( const column_view& column, rounding_frequency freq, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] add_calendrical_months( const column_view& timestamps, const column_view& months, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] add_calendrical_months( const column_view& timestamps, const scalar& months, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] day_of_year( const column_view& column, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] is_leap_year( const column_view& column, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] last_day_of_month( const column_view& column, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] extract_quarter( const column_view& column, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] days_in_month( const column_view& column, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/detail/utilities/stream_pool.pxd b/python/pylibcudf/pylibcudf/libcudf/detail/utilities/stream_pool.pxd index 7aea4aafcd1..399a868db71 100644 --- a/python/pylibcudf/pylibcudf/libcudf/detail/utilities/stream_pool.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/detail/utilities/stream_pool.pxd @@ -1,14 +1,31 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 +from cuda.bindings.cyruntime cimport cudaStream_t from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.utilities.span cimport host_span -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +ctypedef const cudaStream_t const_cudaStream_t -cdef extern from "cudf/detail/utilities/stream_pool.hpp" namespace "cudf::detail" nogil: - cdef void join_streams( - host_span[const cuda_stream_view] streams, - cuda_stream_view stream +cdef extern from * nogil: + """ + #include + #include + #include + #include + + namespace { + void join_streams_wrapper( + cudf::host_span streams, + cudaStream_t stream + ) { + std::vector stream_views(streams.begin(), streams.end()); + cudf::detail::join_streams(stream_views, stream); + } + } + """ + cdef void join_streams "join_streams_wrapper"( + host_span[const_cudaStream_t] streams, + cudaStream_t stream ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/distinct_count.pxd b/python/pylibcudf/pylibcudf/libcudf/distinct_count.pxd index 5707f34f578..2cbf79c0c17 100644 --- a/python/pylibcudf/pylibcudf/libcudf/distinct_count.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/distinct_count.pxd @@ -9,7 +9,7 @@ from pylibcudf.libcudf.types cimport ( null_policy, size_type, ) -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t cdef extern from "cudf/reduction/distinct_count.hpp" namespace "cudf" nogil: @@ -17,9 +17,9 @@ cdef extern from "cudf/reduction/distinct_count.hpp" namespace "cudf" nogil: column_view column, null_policy null_handling, nan_policy nan_handling, - cuda_stream_view stream) except +libcudf_exception_handler + cudaStream_t stream) except +libcudf_exception_handler cdef size_type distinct_count( table_view source_table, null_equality nulls_equal, - cuda_stream_view stream) except +libcudf_exception_handler + cudaStream_t stream) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/filling.pxd b/python/pylibcudf/pylibcudf/libcudf/filling.pxd index ac969cb8822..e9470a828a7 100644 --- a/python/pylibcudf/pylibcudf/libcudf/filling.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/filling.pxd @@ -12,7 +12,7 @@ from pylibcudf.libcudf.scalar.scalar cimport scalar from pylibcudf.libcudf.table.table cimport table from pylibcudf.libcudf.table.table_view cimport table_view from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -22,7 +22,7 @@ cdef extern from "cudf/filling.hpp" namespace "cudf" nogil: size_type begin, size_type end, const scalar & value, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -31,20 +31,20 @@ cdef extern from "cudf/filling.hpp" namespace "cudf" nogil: size_type begin, size_type end, const scalar & value, - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler cdef unique_ptr[table] repeat( const table_view & input, const column_view & count, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[table] repeat( const table_view & input, size_type count, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -52,7 +52,7 @@ cdef extern from "cudf/filling.hpp" namespace "cudf" nogil: size_type size, const scalar & init, const scalar & step, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -60,6 +60,6 @@ cdef extern from "cudf/filling.hpp" namespace "cudf" nogil: size_type n, const scalar& init, size_type months, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/groupby.pxd b/python/pylibcudf/pylibcudf/libcudf/groupby.pxd index 5ba69a12290..b5ba1031813 100644 --- a/python/pylibcudf/pylibcudf/libcudf/groupby.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/groupby.pxd @@ -24,7 +24,7 @@ from pylibcudf.libcudf.types cimport ( sorted, ) -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref # workaround for https://github.com/cython/cython/issues/3885 @@ -67,7 +67,7 @@ cdef extern from "cudf/groupby.hpp" \ vector[aggregation_result] ] aggregate( const vector[aggregation_request]& requests, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -76,7 +76,7 @@ cdef extern from "cudf/groupby.hpp" \ vector[aggregation_result] ] scan( const vector[scan_request]& requests, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -87,19 +87,19 @@ cdef extern from "cudf/groupby.hpp" \ const table_view values, const vector[size_type] offset, const vector[reference_wrapper[constscalar]] fill_values, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler groups get_groups( table_view values, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler pair[unique_ptr[table], unique_ptr[table]] replace_nulls( const table_view& values, const vector[replace_policy] replace_policy, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/hash.pxd b/python/pylibcudf/pylibcudf/libcudf/hash.pxd index 380afc96c58..9610fa2a09f 100644 --- a/python/pylibcudf/pylibcudf/libcudf/hash.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/hash.pxd @@ -7,7 +7,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.table.table cimport table from pylibcudf.libcudf.table.table_view cimport table_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -15,64 +15,64 @@ cdef extern from "cudf/hashing.hpp" namespace "cudf::hashing" nogil: cdef unique_ptr[column] murmurhash3_x86_32( const table_view& input, const uint32_t seed, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[table] murmurhash3_x64_128( const table_view& input, const uint64_t seed, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] md5( const table_view& input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] sha1( const table_view& input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] sha224( const table_view& input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] sha256( const table_view& input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] sha384( const table_view& input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] sha512( const table_view& input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] xxhash_32( const table_view& input, const uint32_t seed, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] xxhash_64( const table_view& input, const uint64_t seed, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/interop.pxd b/python/pylibcudf/pylibcudf/libcudf/interop.pxd index b09524a257b..78fc455dd35 100644 --- a/python/pylibcudf/pylibcudf/libcudf/interop.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/interop.pxd @@ -12,7 +12,7 @@ from pylibcudf.libcudf.scalar.scalar cimport scalar from pylibcudf.libcudf.table.table cimport table from pylibcudf.libcudf.table.table_view cimport table_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -40,13 +40,13 @@ cdef extern from "cudf/interop.hpp" namespace "cudf" \ nogil: cdef unique_ptr[table] from_dlpack( const DLManagedTensor* managed_tensor, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler DLManagedTensor* to_dlpack( const table_view& input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -65,18 +65,18 @@ cdef extern from "cudf/interop.hpp" namespace "cudf::interop" \ arrow_column( ArrowSchema&& schema, ArrowArray&& array, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler arrow_column( ArrowSchema&& schema, ArrowDeviceArray&& array, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler arrow_column( ArrowArrayStream&& stream, - cuda_stream_view cuda_stream, + cudaStream_t cuda_stream, device_async_resource_ref mr ) except +libcudf_exception_handler column_view view() except +libcudf_exception_handler @@ -84,13 +84,13 @@ cdef extern from "cudf/interop.hpp" namespace "cudf::interop" \ cdef cppclass arrow_table: arrow_table( ArrowArrayStream&& stream, - cuda_stream_view cuda_stream, + cudaStream_t cuda_stream, device_async_resource_ref mr ) except +libcudf_exception_handler arrow_table( ArrowSchema&& schema, ArrowDeviceArray&& array, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler table_view view() except +libcudf_exception_handler @@ -135,7 +135,7 @@ cdef extern from *: template ArrowArray* to_arrow_host_raw( ViewType const& obj, - rmm::cuda_stream_view stream, + cudaStream_t stream, rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref()) { ArrowArray *arr = new ArrowArray(); auto device_arr = cudf::to_arrow_host(obj, stream, mr); @@ -175,7 +175,7 @@ cdef extern from *: ArrowDeviceArray* to_arrow_device_raw( ViewType const& obj, PyObject* owner, - rmm::cuda_stream_view stream = cudf::get_default_stream(), + cudaStream_t stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref()) { auto tmp = cudf::to_arrow_device(obj, stream, mr); @@ -222,11 +222,11 @@ cdef extern from *: ) except +libcudf_exception_handler nogil cdef ArrowArray* to_arrow_host_raw( const table_view& tbl, - cuda_stream_view stream, + cudaStream_t stream, ) except +libcudf_exception_handler nogil cdef ArrowArray* to_arrow_host_raw( const column_view& tbl, - cuda_stream_view stream, + cudaStream_t stream, ) except +libcudf_exception_handler nogil cdef void release_arrow_array_raw( ArrowArray * diff --git a/python/pylibcudf/pylibcudf/libcudf/io/avro.pxd b/python/pylibcudf/pylibcudf/libcudf/io/avro.pxd index ff84ad922fc..521147218bf 100644 --- a/python/pylibcudf/pylibcudf/libcudf/io/avro.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/io/avro.pxd @@ -5,7 +5,7 @@ from libcpp.string cimport string from libcpp.vector cimport vector from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -49,6 +49,6 @@ cdef extern from "cudf/io/avro.hpp" namespace "cudf::io" nogil: cdef cudf_io_types.table_with_metadata read_avro( avro_reader_options &options, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/io/csv.pxd b/python/pylibcudf/pylibcudf/libcudf/io/csv.pxd index 31f626b7d9d..45987fbedcd 100644 --- a/python/pylibcudf/pylibcudf/libcudf/io/csv.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/io/csv.pxd @@ -10,7 +10,7 @@ from libcpp.string cimport string from libcpp.vector cimport vector from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.types cimport data_type, size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref cdef extern from "cudf/io/csv.hpp" \ @@ -263,7 +263,7 @@ cdef extern from "cudf/io/csv.hpp" \ cdef cudf_io_types.table_with_metadata read_csv( csv_reader_options &options, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -337,7 +337,7 @@ cdef extern from "cudf/io/csv.hpp" \ cdef void write_csv( csv_writer_options args, - cuda_stream_view stream, + cudaStream_t stream, ) except +libcudf_exception_handler cdef bool is_supported_write_csv( diff --git a/python/pylibcudf/pylibcudf/libcudf/io/hybrid_scan.pxd b/python/pylibcudf/pylibcudf/libcudf/io/hybrid_scan.pxd index 9f7462f6b86..8578908fc43 100644 --- a/python/pylibcudf/pylibcudf/libcudf/io/hybrid_scan.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/io/hybrid_scan.pxd @@ -15,7 +15,7 @@ from pylibcudf.libcudf.io.text cimport byte_range_info from pylibcudf.libcudf.io.types cimport table_with_metadata from pylibcudf.libcudf.types cimport size_type from pylibcudf.libcudf.utilities.span cimport device_span, host_span -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref ctypedef const uint8_t const_uint8_t @@ -61,7 +61,7 @@ cdef extern from "cudf/io/experimental/hybrid_scan.hpp" \ vector[size_type] filter_row_groups_with_stats( host_span[const_size_type] row_group_indices, const parquet_reader_options& options, - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler pair[ @@ -75,20 +75,20 @@ cdef extern from "cudf/io/experimental/hybrid_scan.hpp" \ host_span[const_device_span_const_uint8_t] dictionary_page_data, host_span[const_size_type] row_group_indices, const parquet_reader_options& options, - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler vector[size_type] filter_row_groups_with_bloom_filters( host_span[const_device_span_const_uint8_t] bloom_filter_data, host_span[const_size_type] row_group_indices, const parquet_reader_options& options, - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler unique_ptr[column] build_row_mask_with_page_index_stats( host_span[const_size_type] row_group_indices, const parquet_reader_options& options, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -103,7 +103,7 @@ cdef extern from "cudf/io/experimental/hybrid_scan.hpp" \ mutable_column_view& row_mask, use_data_page_mask mask_data_pages, const parquet_reader_options& options, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -118,7 +118,7 @@ cdef extern from "cudf/io/experimental/hybrid_scan.hpp" \ const column_view& row_mask, use_data_page_mask mask_data_pages, const parquet_reader_options& options, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -131,7 +131,7 @@ cdef extern from "cudf/io/experimental/hybrid_scan.hpp" \ host_span[const_size_type] row_group_indices, host_span[const_device_span_const_uint8_t] column_chunk_data, const parquet_reader_options& options, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -143,7 +143,7 @@ cdef extern from "cudf/io/experimental/hybrid_scan.hpp" \ use_data_page_mask mask_data_pages, host_span[const_device_span_const_uint8_t] column_chunk_data, const parquet_reader_options& options, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -159,7 +159,7 @@ cdef extern from "cudf/io/experimental/hybrid_scan.hpp" \ use_data_page_mask mask_data_pages, host_span[const_device_span_const_uint8_t] column_chunk_data, const parquet_reader_options& options, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/io/json.pxd b/python/pylibcudf/pylibcudf/libcudf/io/json.pxd index 6d5a506d18a..af3b1e59bd1 100644 --- a/python/pylibcudf/pylibcudf/libcudf/io/json.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/io/json.pxd @@ -11,7 +11,7 @@ from libcpp.string cimport string from libcpp.vector cimport vector from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.types cimport data_type, size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -158,7 +158,7 @@ cdef extern from "cudf/io/json.hpp" namespace "cudf::io" nogil: cdef cudf_io_types.table_with_metadata read_json( json_reader_options &options, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -240,7 +240,7 @@ cdef extern from "cudf/io/json.hpp" namespace "cudf::io" nogil: cdef cudf_io_types.table_with_metadata write_json( json_writer_options &options, - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler cdef bool is_supported_write_json( diff --git a/python/pylibcudf/pylibcudf/libcudf/io/orc.pxd b/python/pylibcudf/pylibcudf/libcudf/io/orc.pxd index 0455c0fa1b1..bea5c1e06f0 100644 --- a/python/pylibcudf/pylibcudf/libcudf/io/orc.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/io/orc.pxd @@ -11,7 +11,7 @@ from libcpp.string cimport string from libcpp.vector cimport vector from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.types cimport data_type, size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -80,7 +80,7 @@ cdef extern from "cudf/io/orc.hpp" namespace "cudf::io" nogil: cdef cudf_io_types.table_with_metadata read_orc( orc_reader_options opts, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr, ) except +libcudf_exception_handler @@ -150,7 +150,7 @@ cdef extern from "cudf/io/orc.hpp" namespace "cudf::io" nogil: cdef void write_orc( orc_writer_options options, - cuda_stream_view stream, + cudaStream_t stream, ) except +libcudf_exception_handler cdef bool is_supported_read_orc( @@ -228,7 +228,7 @@ cdef extern from "cudf/io/orc.hpp" namespace "cudf::io" nogil: orc_chunked_writer() except +libcudf_exception_handler orc_chunked_writer( chunked_orc_writer_options args, - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler orc_chunked_writer& write( cudf_table_view.table_view table_, diff --git a/python/pylibcudf/pylibcudf/libcudf/io/orc_metadata.pxd b/python/pylibcudf/pylibcudf/libcudf/io/orc_metadata.pxd index e0c67e14e1d..f365a45b34a 100644 --- a/python/pylibcudf/pylibcudf/libcudf/io/orc_metadata.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/io/orc_metadata.pxd @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2020-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libc.stdint cimport int32_t, int64_t, uint32_t, uint64_t from libcpp cimport bool @@ -8,7 +8,7 @@ from libcpp.vector cimport vector from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.io cimport types as cudf_io_types from pylibcudf.variant cimport monostate, variant -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t cdef extern from "cudf/io/orc_metadata.hpp" \ @@ -71,5 +71,5 @@ cdef extern from "cudf/io/orc_metadata.hpp" \ cdef parsed_orc_statistics read_parsed_orc_statistics( const cudf_io_types.source_info& src_info, - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/io/parquet.pxd b/python/pylibcudf/pylibcudf/libcudf/io/parquet.pxd index dc0dff818a3..00b62e55514 100644 --- a/python/pylibcudf/pylibcudf/libcudf/io/parquet.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/io/parquet.pxd @@ -22,7 +22,7 @@ from pylibcudf.libcudf.io.types cimport ( ) from pylibcudf.libcudf.table.table_view cimport table_view from pylibcudf.libcudf.types cimport data_type, size_type, type_id -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -124,7 +124,7 @@ cdef extern from "cudf/io/parquet.hpp" namespace "cudf::io" nogil: cdef table_with_metadata read_parquet( parquet_reader_options args, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -256,7 +256,7 @@ cdef extern from "cudf/io/parquet.hpp" namespace "cudf::io" nogil: cdef unique_ptr[vector[uint8_t]] write_parquet( parquet_writer_options options, - cuda_stream_view stream, + cudaStream_t stream, ) except +libcudf_exception_handler cdef bool is_supported_read_parquet( @@ -288,7 +288,7 @@ cdef extern from "cudf/io/parquet.hpp" namespace "cudf::io" nogil: chunked_parquet_writer() except +libcudf_exception_handler chunked_parquet_writer( const chunked_parquet_writer_options& args, - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler chunked_parquet_writer& write( const table_view& table_, @@ -303,14 +303,14 @@ cdef extern from "cudf/io/parquet.hpp" namespace "cudf::io" nogil: chunked_parquet_reader( size_t chunk_read_limit, const parquet_reader_options& options, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler chunked_parquet_reader( size_t chunk_read_limit, size_t pass_read_limit, const parquet_reader_options& options, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler bool has_next() except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/io/text.pxd b/python/pylibcudf/pylibcudf/libcudf/io/text.pxd index 77552a80cfd..7152e5d0afb 100644 --- a/python/pylibcudf/pylibcudf/libcudf/io/text.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/io/text.pxd @@ -6,7 +6,7 @@ from libcpp.memory cimport unique_ptr from libcpp.string cimport string from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -63,6 +63,6 @@ cdef extern from "cudf/io/text/multibyte_split.hpp" \ data_chunk_source source, string delimiter, parse_options options, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/io/timezone.pxd b/python/pylibcudf/pylibcudf/libcudf/io/timezone.pxd index 557e8856b28..45cfb4f15da 100644 --- a/python/pylibcudf/pylibcudf/libcudf/io/timezone.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/io/timezone.pxd @@ -6,7 +6,7 @@ from libcpp.optional cimport optional from libcpp.string cimport string from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.table.table cimport table -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -14,6 +14,6 @@ cdef extern from "cudf/timezone.hpp" namespace "cudf" nogil: unique_ptr[table] make_timezone_transition_table( optional[string] tzif_dir, string timezone_name, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/join.pxd b/python/pylibcudf/pylibcudf/libcudf/join.pxd index 06a7d497ad5..d13bf245119 100644 --- a/python/pylibcudf/pylibcudf/libcudf/join.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/join.pxd @@ -13,7 +13,7 @@ from pylibcudf.libcudf.expressions cimport expression from pylibcudf.libcudf.table.table cimport table from pylibcudf.libcudf.table.table_view cimport table_view from pylibcudf.libcudf.types cimport null_equality, size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref from rmm.librmm.device_uvector cimport device_uvector @@ -28,7 +28,7 @@ cdef extern from "cudf/join/join.hpp" namespace "cudf" nogil: const table_view left_keys, const table_view right_keys, null_equality nulls_equal, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -36,7 +36,7 @@ cdef extern from "cudf/join/join.hpp" namespace "cudf" nogil: const table_view left_keys, const table_view right_keys, null_equality nulls_equal, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -44,7 +44,7 @@ cdef extern from "cudf/join/join.hpp" namespace "cudf" nogil: const table_view left_keys, const table_view right_keys, null_equality nulls_equal, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -52,7 +52,7 @@ cdef extern from "cudf/join/join.hpp" namespace "cudf" nogil: const table_view left_keys, const table_view right_keys, null_equality nulls_equal, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -60,7 +60,7 @@ cdef extern from "cudf/join/join.hpp" namespace "cudf" nogil: const table_view left_keys, const table_view right_keys, null_equality nulls_equal, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -68,14 +68,14 @@ cdef extern from "cudf/join/join.hpp" namespace "cudf" nogil: const table_view left_keys, const table_view right_keys, null_equality nulls_equal, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[table] cross_join( const table_view left, const table_view right, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -84,7 +84,7 @@ cdef extern from "cudf/join/conditional_join.hpp" namespace "cudf" nogil: const table_view left, const table_view right, const expression binary_predicate, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -93,7 +93,7 @@ cdef extern from "cudf/join/conditional_join.hpp" namespace "cudf" nogil: const table_view right, const expression binary_predicate, optional[size_t] output_size, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -101,7 +101,7 @@ cdef extern from "cudf/join/conditional_join.hpp" namespace "cudf" nogil: const table_view left, const table_view right, const expression binary_predicate, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -110,7 +110,7 @@ cdef extern from "cudf/join/conditional_join.hpp" namespace "cudf" nogil: const table_view right, const expression binary_predicate, optional[size_t] output_size, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -118,7 +118,7 @@ cdef extern from "cudf/join/conditional_join.hpp" namespace "cudf" nogil: const table_view left, const table_view right, const expression binary_predicate, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -126,7 +126,7 @@ cdef extern from "cudf/join/conditional_join.hpp" namespace "cudf" nogil: const table_view left, const table_view right, const expression binary_predicate, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -135,7 +135,7 @@ cdef extern from "cudf/join/conditional_join.hpp" namespace "cudf" nogil: const table_view right, const expression binary_predicate, optional[size_t] output_size, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -143,7 +143,7 @@ cdef extern from "cudf/join/conditional_join.hpp" namespace "cudf" nogil: const table_view left, const table_view right, const expression binary_predicate, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -152,7 +152,7 @@ cdef extern from "cudf/join/conditional_join.hpp" namespace "cudf" nogil: const table_view right, const expression binary_predicate, optional[size_t] output_size, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -165,7 +165,7 @@ cdef extern from "cudf/join/mixed_join.hpp" namespace "cudf" nogil: const expression binary_predicate, null_equality compare_nulls, output_size_data_type output_size_data, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -177,7 +177,7 @@ cdef extern from "cudf/join/mixed_join.hpp" namespace "cudf" nogil: const expression binary_predicate, null_equality compare_nulls, output_size_data_type output_size_data, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -189,7 +189,7 @@ cdef extern from "cudf/join/mixed_join.hpp" namespace "cudf" nogil: const expression binary_predicate, null_equality compare_nulls, output_size_data_type output_size_data, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -200,7 +200,7 @@ cdef extern from "cudf/join/mixed_join.hpp" namespace "cudf" nogil: const table_view right_conditional, const expression binary_predicate, null_equality compare_nulls, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -211,7 +211,7 @@ cdef extern from "cudf/join/mixed_join.hpp" namespace "cudf" nogil: const table_view right_conditional, const expression binary_predicate, null_equality compare_nulls, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -225,21 +225,21 @@ cdef extern from "cudf/join/filtered_join.hpp" namespace "cudf" nogil: filtered_join( const table_view build, null_equality compare_nulls, - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler filtered_join( const table_view build, null_equality compare_nulls, double load_factor, - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler gather_map_type semi_join( const table_view probe, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler gather_map_type anti_join( const table_view probe, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/json.pxd b/python/pylibcudf/pylibcudf/libcudf/json.pxd index 39899490cac..bb606b86b33 100644 --- a/python/pylibcudf/pylibcudf/libcudf/json.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/json.pxd @@ -8,7 +8,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport scalar, string_scalar -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -30,6 +30,6 @@ cdef extern from "cudf/json/json.hpp" namespace "cudf" nogil: column_view col, string_scalar json_path, get_json_object_options options, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/labeling.pxd b/python/pylibcudf/pylibcudf/libcudf/labeling.pxd index ad9611511dd..0b2c1651714 100644 --- a/python/pylibcudf/pylibcudf/libcudf/labeling.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/labeling.pxd @@ -6,7 +6,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -21,6 +21,6 @@ cdef extern from "cudf/labeling/label_bins.hpp" namespace "cudf" nogil: inclusive left_inclusive, const column_view &right_edges, inclusive right_inclusive, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/lists/combine.pxd b/python/pylibcudf/pylibcudf/libcudf/lists/combine.pxd index 66e90dcd66a..310d166df59 100644 --- a/python/pylibcudf/pylibcudf/libcudf/lists/combine.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/lists/combine.pxd @@ -7,7 +7,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.table.table_view cimport table_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -21,19 +21,19 @@ cdef extern from "cudf/lists/combine.hpp" namespace \ cdef unique_ptr[column] concatenate_rows( const table_view input_table, concatenate_null_policy null_policy, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] concatenate_list_elements( const table_view input_table, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] concatenate_list_elements( const column_view input_table, concatenate_null_policy null_policy, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/lists/contains.pxd b/python/pylibcudf/pylibcudf/libcudf/lists/contains.pxd index efb2d760366..3736e42b32d 100644 --- a/python/pylibcudf/pylibcudf/libcudf/lists/contains.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/lists/contains.pxd @@ -7,7 +7,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.lists.lists_column_view cimport lists_column_view from pylibcudf.libcudf.scalar.scalar cimport scalar -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -20,20 +20,20 @@ cdef extern from "cudf/lists/contains.hpp" namespace "cudf::lists" nogil: cdef unique_ptr[column] contains( const lists_column_view& lists, const scalar& search_key, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] contains( const lists_column_view& lists, const column_view& search_keys, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] contains_nulls( const lists_column_view& lists, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -41,7 +41,7 @@ cdef extern from "cudf/lists/contains.hpp" namespace "cudf::lists" nogil: const lists_column_view& lists, const scalar& search_key, duplicate_find_option find_option, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -49,6 +49,6 @@ cdef extern from "cudf/lists/contains.hpp" namespace "cudf::lists" nogil: const lists_column_view& lists, const column_view& search_keys, duplicate_find_option find_option, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/lists/count_elements.pxd b/python/pylibcudf/pylibcudf/libcudf/lists/count_elements.pxd index 6203bafdc38..6fa64c8b291 100644 --- a/python/pylibcudf/pylibcudf/libcudf/lists/count_elements.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/lists/count_elements.pxd @@ -4,13 +4,13 @@ from libcpp.memory cimport unique_ptr from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.lists.lists_column_view cimport lists_column_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref cdef extern from "cudf/lists/count_elements.hpp" namespace "cudf::lists" nogil: cdef unique_ptr[column] count_elements( const lists_column_view&, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/lists/explode.pxd b/python/pylibcudf/pylibcudf/libcudf/lists/explode.pxd index b31d3a7cdca..fa15fb1eeef 100644 --- a/python/pylibcudf/pylibcudf/libcudf/lists/explode.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/lists/explode.pxd @@ -5,7 +5,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.table.table cimport table from pylibcudf.libcudf.table.table_view cimport table_view from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -13,6 +13,6 @@ cdef extern from "cudf/lists/explode.hpp" namespace "cudf" nogil: cdef unique_ptr[table] explode_outer( const table_view, size_type explode_column_idx, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/lists/extract.pxd b/python/pylibcudf/pylibcudf/libcudf/lists/extract.pxd index c82a9029311..66a07f41e38 100644 --- a/python/pylibcudf/pylibcudf/libcudf/lists/extract.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/lists/extract.pxd @@ -5,7 +5,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column, column_view from pylibcudf.libcudf.lists.lists_column_view cimport lists_column_view from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -13,12 +13,12 @@ cdef extern from "cudf/lists/extract.hpp" namespace "cudf::lists" nogil: cdef unique_ptr[column] extract_list_element( const lists_column_view&, size_type, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] extract_list_element( const lists_column_view&, const column_view&, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/lists/filling.pxd b/python/pylibcudf/pylibcudf/libcudf/lists/filling.pxd index 11cc19b86f9..1e55916d299 100644 --- a/python/pylibcudf/pylibcudf/libcudf/lists/filling.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/lists/filling.pxd @@ -4,7 +4,7 @@ from libcpp.memory cimport unique_ptr from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -12,7 +12,7 @@ cdef extern from "cudf/lists/filling.hpp" namespace "cudf::lists" nogil: cdef unique_ptr[column] sequences( const column_view& starts, const column_view& sizes, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -20,6 +20,6 @@ cdef extern from "cudf/lists/filling.hpp" namespace "cudf::lists" nogil: const column_view& starts, const column_view& steps, const column_view& sizes, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/lists/gather.pxd b/python/pylibcudf/pylibcudf/libcudf/lists/gather.pxd index bae67a96b0d..b7212bea51e 100644 --- a/python/pylibcudf/pylibcudf/libcudf/lists/gather.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/lists/gather.pxd @@ -5,7 +5,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.copying cimport out_of_bounds_policy from pylibcudf.libcudf.lists.lists_column_view cimport lists_column_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref cdef extern from "cudf/lists/gather.hpp" namespace "cudf::lists" nogil: @@ -13,6 +13,6 @@ cdef extern from "cudf/lists/gather.hpp" namespace "cudf::lists" nogil: const lists_column_view& source_column, const lists_column_view& gather_map_list, out_of_bounds_policy bounds_policy, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/lists/lists_column_view.pxd b/python/pylibcudf/pylibcudf/libcudf/lists/lists_column_view.pxd index fe1630c1728..69a6c80f242 100644 --- a/python/pylibcudf/pylibcudf/libcudf/lists/lists_column_view.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/lists/lists_column_view.pxd @@ -1,6 +1,6 @@ # SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column_view cimport ( @@ -26,7 +26,7 @@ cdef extern from "cudf/lists/lists_column_view.hpp" namespace "cudf" nogil: column_view offsets() except +libcudf_exception_handler column_view child() except +libcudf_exception_handler column_view get_sliced_child( - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler cdef enum: diff --git a/python/pylibcudf/pylibcudf/libcudf/lists/reverse.pxd b/python/pylibcudf/pylibcudf/libcudf/lists/reverse.pxd index f831024ec82..e60c8acbb38 100644 --- a/python/pylibcudf/pylibcudf/libcudf/lists/reverse.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/lists/reverse.pxd @@ -4,13 +4,13 @@ from libcpp.memory cimport unique_ptr from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.lists.lists_column_view cimport lists_column_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref cdef extern from "cudf/lists/reverse.hpp" namespace "cudf::lists" nogil: cdef unique_ptr[column] reverse( const lists_column_view& lists_column, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/lists/set_operations.pxd b/python/pylibcudf/pylibcudf/libcudf/lists/set_operations.pxd index 5e02d11d95a..b56caa9adb5 100644 --- a/python/pylibcudf/pylibcudf/libcudf/lists/set_operations.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/lists/set_operations.pxd @@ -5,7 +5,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.lists.lists_column_view cimport lists_column_view from pylibcudf.libcudf.types cimport nan_equality, null_equality -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -15,7 +15,7 @@ cdef extern from "cudf/lists/set_operations.hpp" namespace "cudf::lists" nogil: const lists_column_view& rhs, null_equality nulls_equal, nan_equality nans_equal, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -24,7 +24,7 @@ cdef extern from "cudf/lists/set_operations.hpp" namespace "cudf::lists" nogil: const lists_column_view& rhs, null_equality nulls_equal, nan_equality nans_equal, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -33,7 +33,7 @@ cdef extern from "cudf/lists/set_operations.hpp" namespace "cudf::lists" nogil: const lists_column_view& rhs, null_equality nulls_equal, nan_equality nans_equal, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -42,6 +42,6 @@ cdef extern from "cudf/lists/set_operations.hpp" namespace "cudf::lists" nogil: const lists_column_view& rhs, null_equality nulls_equal, nan_equality nans_equal, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/lists/sorting.pxd b/python/pylibcudf/pylibcudf/libcudf/lists/sorting.pxd index 4036ccec6c5..9899591d6d1 100644 --- a/python/pylibcudf/pylibcudf/libcudf/lists/sorting.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/lists/sorting.pxd @@ -5,7 +5,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.lists.lists_column_view cimport lists_column_view from pylibcudf.libcudf.types cimport null_order, order -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -14,7 +14,7 @@ cdef extern from "cudf/lists/sorting.hpp" namespace "cudf::lists" nogil: const lists_column_view source_column, order column_order, null_order null_precedence, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -22,6 +22,6 @@ cdef extern from "cudf/lists/sorting.hpp" namespace "cudf::lists" nogil: const lists_column_view source_column, order column_order, null_order null_precedence, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/lists/stream_compaction.pxd b/python/pylibcudf/pylibcudf/libcudf/lists/stream_compaction.pxd index dec32027402..0187642e0c7 100644 --- a/python/pylibcudf/pylibcudf/libcudf/lists/stream_compaction.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/lists/stream_compaction.pxd @@ -6,7 +6,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.lists.lists_column_view cimport lists_column_view from pylibcudf.libcudf.stream_compaction cimport duplicate_keep_option from pylibcudf.libcudf.types cimport nan_equality, null_equality -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -15,7 +15,7 @@ cdef extern from "cudf/lists/stream_compaction.hpp" \ cdef unique_ptr[column] apply_boolean_mask( const lists_column_view& lists_column, const lists_column_view& boolean_mask, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -24,6 +24,6 @@ cdef extern from "cudf/lists/stream_compaction.hpp" \ null_equality nulls_equal, nan_equality nans_equal, duplicate_keep_option keep_option, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/merge.pxd b/python/pylibcudf/pylibcudf/libcudf/merge.pxd index 860e4263c1c..f4389ac991a 100644 --- a/python/pylibcudf/pylibcudf/libcudf/merge.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/merge.pxd @@ -7,7 +7,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.table.table cimport table from pylibcudf.libcudf.table.table_view cimport table_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -17,6 +17,6 @@ cdef extern from "cudf/merge.hpp" namespace "cudf" nogil: vector[libcudf_types.size_type] key_cols, vector[libcudf_types.order] column_order, vector[libcudf_types.null_order] null_precedence, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/null_mask.pxd b/python/pylibcudf/pylibcudf/libcudf/null_mask.pxd index 1b1b3001981..330c69f0579 100644 --- a/python/pylibcudf/pylibcudf/libcudf/null_mask.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/null_mask.pxd @@ -8,14 +8,14 @@ from pylibcudf.libcudf.table.table_view cimport table_view from pylibcudf.libcudf.types cimport bitmask_type, mask_state, size_type from rmm.librmm.device_buffer cimport device_buffer -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref cdef extern from "cudf/null_mask.hpp" namespace "cudf" nogil: cdef device_buffer copy_bitmask ( column_view view, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -23,7 +23,7 @@ cdef extern from "cudf/null_mask.hpp" namespace "cudf" nogil: const bitmask_type* null_mask, size_type begin_bit, size_type end_bit, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -35,19 +35,19 @@ cdef extern from "cudf/null_mask.hpp" namespace "cudf" nogil: cdef device_buffer create_null_mask ( size_type size, mask_state state, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef pair[device_buffer, size_type] bitmask_and( table_view view, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) cdef pair[device_buffer, size_type] bitmask_or( table_view view, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) @@ -55,12 +55,12 @@ cdef extern from "cudf/null_mask.hpp" namespace "cudf" nogil: const bitmask_type * bitmask, size_type start, size_type stop, - cuda_stream_view stream + cudaStream_t stream ) cdef size_type index_of_first_set_bit( const bitmask_type * bitmask, size_type start, size_type stop, - cuda_stream_view stream + cudaStream_t stream ) diff --git a/python/pylibcudf/pylibcudf/libcudf/nvtext/byte_pair_encode.pxd b/python/pylibcudf/pylibcudf/libcudf/nvtext/byte_pair_encode.pxd index eca30faa630..94a7fe3db9d 100644 --- a/python/pylibcudf/pylibcudf/libcudf/nvtext/byte_pair_encode.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/nvtext/byte_pair_encode.pxd @@ -6,7 +6,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport string_scalar -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -17,7 +17,7 @@ cdef extern from "nvtext/byte_pair_encoding.hpp" namespace "nvtext" nogil: cdef unique_ptr[bpe_merge_pairs] load_merge_pairs( const column_view &merge_pairs, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -25,6 +25,6 @@ cdef extern from "nvtext/byte_pair_encoding.hpp" namespace "nvtext" nogil: const column_view &strings, const bpe_merge_pairs &merge_pairs, const string_scalar &separator, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/nvtext/deduplicate.pxd b/python/pylibcudf/pylibcudf/libcudf/nvtext/deduplicate.pxd index 26e39c963d2..82a8581ea0a 100644 --- a/python/pylibcudf/pylibcudf/libcudf/nvtext/deduplicate.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/nvtext/deduplicate.pxd @@ -7,7 +7,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref from rmm.librmm.device_uvector cimport device_uvector @@ -19,7 +19,7 @@ cdef extern from "nvtext/deduplicate.hpp" namespace "nvtext" nogil: cdef suffix_array_type build_suffix_array( column_view source_strings, size_type min_width, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -27,7 +27,7 @@ cdef extern from "nvtext/deduplicate.hpp" namespace "nvtext" nogil: column_view source_strings, column_view indices, size_type min_width, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -37,6 +37,6 @@ cdef extern from "nvtext/deduplicate.hpp" namespace "nvtext" nogil: column_view input2, column_view indices2, size_type min_width, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/nvtext/edit_distance.pxd b/python/pylibcudf/pylibcudf/libcudf/nvtext/edit_distance.pxd index b7f3e97a4b0..f3c10c11abf 100644 --- a/python/pylibcudf/pylibcudf/libcudf/nvtext/edit_distance.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/nvtext/edit_distance.pxd @@ -6,7 +6,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -15,12 +15,12 @@ cdef extern from "nvtext/edit_distance.hpp" namespace "nvtext" nogil: cdef unique_ptr[column] edit_distance( const column_view & strings, const column_view & targets, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] edit_distance_matrix( const column_view & strings, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/nvtext/generate_ngrams.pxd b/python/pylibcudf/pylibcudf/libcudf/nvtext/generate_ngrams.pxd index 43619d356f6..3d97aaf93b1 100644 --- a/python/pylibcudf/pylibcudf/libcudf/nvtext/generate_ngrams.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/nvtext/generate_ngrams.pxd @@ -7,7 +7,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport string_scalar from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -17,14 +17,14 @@ cdef extern from "nvtext/generate_ngrams.hpp" namespace "nvtext" nogil: const column_view &strings, size_type ngrams, const string_scalar & separator, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] generate_character_ngrams( const column_view &strings, size_type ngrams, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -32,6 +32,6 @@ cdef extern from "nvtext/generate_ngrams.hpp" namespace "nvtext" nogil: const column_view &strings, size_type ngrams, uint32_t seed, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/nvtext/jaccard.pxd b/python/pylibcudf/pylibcudf/libcudf/nvtext/jaccard.pxd index de45913fbb5..0a3ba52a3d5 100644 --- a/python/pylibcudf/pylibcudf/libcudf/nvtext/jaccard.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/nvtext/jaccard.pxd @@ -5,7 +5,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -15,6 +15,6 @@ cdef extern from "nvtext/jaccard.hpp" namespace "nvtext" nogil: const column_view &input1, const column_view &input2, size_type width, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/nvtext/minhash.pxd b/python/pylibcudf/pylibcudf/libcudf/nvtext/minhash.pxd index eaf0b8c63b1..94083fbafd3 100644 --- a/python/pylibcudf/pylibcudf/libcudf/nvtext/minhash.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/nvtext/minhash.pxd @@ -7,7 +7,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport numeric_scalar from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -19,7 +19,7 @@ cdef extern from "nvtext/minhash.hpp" namespace "nvtext" nogil: const column_view &a, const column_view &b, const size_type width, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -29,7 +29,7 @@ cdef extern from "nvtext/minhash.hpp" namespace "nvtext" nogil: const column_view &a, const column_view &b, const size_type width, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -39,7 +39,7 @@ cdef extern from "nvtext/minhash.hpp" namespace "nvtext" nogil: const uint32_t seed, const column_view &a, const column_view &b, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -49,6 +49,6 @@ cdef extern from "nvtext/minhash.hpp" namespace "nvtext" nogil: const uint64_t seed, const column_view &a, const column_view &b, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/nvtext/ngrams_tokenize.pxd b/python/pylibcudf/pylibcudf/libcudf/nvtext/ngrams_tokenize.pxd index 41d153b99a0..6e4cc18e17f 100644 --- a/python/pylibcudf/pylibcudf/libcudf/nvtext/ngrams_tokenize.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/nvtext/ngrams_tokenize.pxd @@ -6,7 +6,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport string_scalar from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -17,6 +17,6 @@ cdef extern from "nvtext/ngrams_tokenize.hpp" namespace "nvtext" nogil: size_type ngrams, const string_scalar & delimiter, const string_scalar & separator, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/nvtext/normalize.pxd b/python/pylibcudf/pylibcudf/libcudf/nvtext/normalize.pxd index 25678d12091..0184c1d8785 100644 --- a/python/pylibcudf/pylibcudf/libcudf/nvtext/normalize.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/nvtext/normalize.pxd @@ -5,7 +5,7 @@ from libcpp.memory cimport unique_ptr from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -13,7 +13,7 @@ cdef extern from "nvtext/normalize.hpp" namespace "nvtext" nogil: cdef unique_ptr[column] normalize_spaces( const column_view & strings, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -23,13 +23,13 @@ cdef extern from "nvtext/normalize.hpp" namespace "nvtext" nogil: cdef unique_ptr[character_normalizer] create_character_normalizer( bool do_lower_case, const column_view & strings, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] normalize_characters( const column_view & strings, const character_normalizer & normalizer, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/nvtext/replace.pxd b/python/pylibcudf/pylibcudf/libcudf/nvtext/replace.pxd index d14ce40b168..628181b3f89 100644 --- a/python/pylibcudf/pylibcudf/libcudf/nvtext/replace.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/nvtext/replace.pxd @@ -6,7 +6,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport string_scalar from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -17,7 +17,7 @@ cdef extern from "nvtext/replace.hpp" namespace "nvtext" nogil: const column_view & targets, const column_view & replacements, const string_scalar & delimiter, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -26,6 +26,6 @@ cdef extern from "nvtext/replace.hpp" namespace "nvtext" nogil: size_type min_token_length, const string_scalar & replacement, const string_scalar & delimiter, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/nvtext/stemmer.pxd b/python/pylibcudf/pylibcudf/libcudf/nvtext/stemmer.pxd index e6e2866008b..2088440749a 100644 --- a/python/pylibcudf/pylibcudf/libcudf/nvtext/stemmer.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/nvtext/stemmer.pxd @@ -7,7 +7,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -18,7 +18,7 @@ cdef extern from "nvtext/stemmer.hpp" namespace "nvtext" nogil: cdef unique_ptr[column] porter_stemmer_measure( const column_view & strings, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -26,12 +26,12 @@ cdef extern from "nvtext/stemmer.hpp" namespace "nvtext" nogil: column_view source_strings, letter_type ltype, size_type character_index, - cuda_stream_view stream) except +libcudf_exception_handler + cudaStream_t stream) except +libcudf_exception_handler cdef unique_ptr[column] is_letter( column_view source_strings, letter_type ltype, column_view indices, - cuda_stream_view stream) except +libcudf_exception_handler + cudaStream_t stream) except +libcudf_exception_handler ctypedef int32_t underlying_type_t_letter_type diff --git a/python/pylibcudf/pylibcudf/libcudf/nvtext/tokenize.pxd b/python/pylibcudf/pylibcudf/libcudf/nvtext/tokenize.pxd index 3b7ae2e9b6f..1c6eccb0476 100644 --- a/python/pylibcudf/pylibcudf/libcudf/nvtext/tokenize.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/nvtext/tokenize.pxd @@ -6,7 +6,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport string_scalar from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -15,34 +15,34 @@ cdef extern from "nvtext/tokenize.hpp" namespace "nvtext" nogil: cdef unique_ptr[column] tokenize( const column_view & strings, const string_scalar & delimiter, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] tokenize( const column_view & strings, const column_view & delimiters, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] count_tokens( const column_view & strings, const string_scalar & delimiter, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] count_tokens( const column_view & strings, const column_view & delimiters, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] character_tokenize( const column_view & strings, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -50,7 +50,7 @@ cdef extern from "nvtext/tokenize.hpp" namespace "nvtext" nogil: const column_view & strings, const column_view & row_indices, const string_scalar & separator, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -59,7 +59,7 @@ cdef extern from "nvtext/tokenize.hpp" namespace "nvtext" nogil: cdef unique_ptr[tokenize_vocabulary] load_vocabulary( const column_view & strings, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -68,6 +68,6 @@ cdef extern from "nvtext/tokenize.hpp" namespace "nvtext" nogil: const tokenize_vocabulary & vocabulary, const string_scalar & delimiter, size_type default_id, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/nvtext/wordpiece_tokenize.pxd b/python/pylibcudf/pylibcudf/libcudf/nvtext/wordpiece_tokenize.pxd index a4bcde47f80..0c43f0d21ff 100644 --- a/python/pylibcudf/pylibcudf/libcudf/nvtext/wordpiece_tokenize.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/nvtext/wordpiece_tokenize.pxd @@ -5,7 +5,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -16,7 +16,7 @@ cdef extern from "nvtext/wordpiece_tokenize.hpp" namespace "nvtext" nogil: cdef unique_ptr[wordpiece_vocabulary] load_wordpiece_vocabulary( const column_view & strings, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -24,6 +24,6 @@ cdef extern from "nvtext/wordpiece_tokenize.hpp" namespace "nvtext" nogil: const column_view & strings, const wordpiece_vocabulary & vocabulary, size_type max_tokens_per_row, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/partitioning.pxd b/python/pylibcudf/pylibcudf/libcudf/partitioning.pxd index e7c0f496de8..2e0c978f77d 100644 --- a/python/pylibcudf/pylibcudf/libcudf/partitioning.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/partitioning.pxd @@ -11,7 +11,7 @@ from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.hash cimport DEFAULT_HASH_SEED from pylibcudf.libcudf.table.table cimport table from pylibcudf.libcudf.table.table_view cimport table_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref cdef extern from "cudf/partitioning.hpp" namespace "cudf" nogil: @@ -28,7 +28,7 @@ cdef extern from "cudf/partitioning.hpp" namespace "cudf" nogil: int num_partitions, hash_id hash_function, uint32_t seed, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -39,7 +39,7 @@ cdef extern from "cudf/partitioning.hpp" namespace "cudf" nogil: int num_partitions, hash_id hash_function, uint32_t seed, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -48,7 +48,7 @@ cdef extern from "cudf/partitioning.hpp" namespace "cudf" nogil: const table_view& t, const column_view& partition_map, int num_partitions, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -57,6 +57,6 @@ cdef extern from "cudf/partitioning.hpp" namespace "cudf" nogil: const table_view& input, int num_partitions, int start_partition, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/quantiles.pxd b/python/pylibcudf/pylibcudf/libcudf/quantiles.pxd index 823bd34e4a7..8bc636da998 100644 --- a/python/pylibcudf/pylibcudf/libcudf/quantiles.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/quantiles.pxd @@ -15,7 +15,7 @@ from pylibcudf.libcudf.types cimport ( order_info, sorted, ) -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -27,7 +27,7 @@ cdef extern from "cudf/quantiles.hpp" namespace "cudf" nogil: interpolation interp, column_view ordered_indices, bool exact, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -38,6 +38,6 @@ cdef extern from "cudf/quantiles.hpp" namespace "cudf" nogil: sorted is_input_sorted, vector[order] column_order, vector[null_order] null_precedence, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/reduce.pxd b/python/pylibcudf/pylibcudf/libcudf/reduce.pxd index 9da4159d0c1..5fb383149a7 100644 --- a/python/pylibcudf/pylibcudf/libcudf/reduce.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/reduce.pxd @@ -11,7 +11,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport scalar from pylibcudf.libcudf.types cimport data_type, null_policy -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref ctypedef const scalar constscalar @@ -22,7 +22,7 @@ cdef extern from "cudf/reduction.hpp" namespace "cudf" nogil: const reduce_aggregation& agg, data_type output_type, optional[reference_wrapper[constscalar]] init, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -35,13 +35,13 @@ cdef extern from "cudf/reduction.hpp" namespace "cudf" nogil: const scan_aggregation& agg, scan_type inclusive, null_policy null_handling, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef pair[unique_ptr[scalar], unique_ptr[scalar]] minmax( const column_view& col, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/replace.pxd b/python/pylibcudf/pylibcudf/libcudf/replace.pxd index 35078b64ee3..4821a13924c 100644 --- a/python/pylibcudf/pylibcudf/libcudf/replace.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/replace.pxd @@ -9,7 +9,7 @@ from pylibcudf.libcudf.column.column_view cimport ( mutable_column_view, ) from pylibcudf.libcudf.scalar.scalar cimport scalar -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -22,47 +22,47 @@ cdef extern from "cudf/replace.hpp" namespace "cudf" nogil: cdef unique_ptr[column] replace_nulls( column_view source_column, column_view replacement_column, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] replace_nulls( column_view source_column, scalar replacement, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] replace_nulls( column_view source_column, replace_policy replace_policy, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] find_and_replace_all( column_view source_column, column_view values_to_replace, column_view replacement_values, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] clamp( column_view source_column, scalar lo, scalar lo_replace, scalar hi, scalar hi_replace, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] clamp( column_view source_column, scalar lo, scalar hi, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] normalize_nans_and_zeros( column_view source_column, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef void normalize_nans_and_zeros( mutable_column_view source_column, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/reshape.pxd b/python/pylibcudf/pylibcudf/libcudf/reshape.pxd index 598e148d643..beda4ec09fc 100644 --- a/python/pylibcudf/pylibcudf/libcudf/reshape.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/reshape.pxd @@ -8,7 +8,7 @@ from pylibcudf.libcudf.table.table_view cimport table_view from pylibcudf.libcudf.types cimport size_type, data_type from pylibcudf.libcudf.utilities.span cimport device_span -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref cdef extern from "cuda/functional" namespace "cuda::std": @@ -19,17 +19,17 @@ cdef extern from "cuda/functional" namespace "cuda::std": cdef extern from "cudf/reshape.hpp" namespace "cudf" nogil: cdef unique_ptr[column] interleave_columns( table_view source_table, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[table] tile( table_view source_table, size_type count, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef void table_to_array( table_view input_table, device_span[byte] output, - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/rolling.pxd b/python/pylibcudf/pylibcudf/libcudf/rolling.pxd index 6ea400f92d3..69cdbd6f396 100644 --- a/python/pylibcudf/pylibcudf/libcudf/rolling.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/rolling.pxd @@ -12,7 +12,7 @@ from pylibcudf.libcudf.scalar.scalar cimport scalar from pylibcudf.libcudf.table.table cimport table from pylibcudf.libcudf.table.table_view cimport table_view from pylibcudf.libcudf.types cimport data_type, null_order, order, size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -44,7 +44,7 @@ cdef extern from "cudf/rolling.hpp" namespace "cudf" nogil: range_window_type preceding, range_window_type following, vector[rolling_request]& requests, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -54,7 +54,7 @@ cdef extern from "cudf/rolling.hpp" namespace "cudf" nogil: column_view following_window, size_type min_periods, rolling_aggregation& agg, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] rolling_window( @@ -63,7 +63,7 @@ cdef extern from "cudf/rolling.hpp" namespace "cudf" nogil: size_type following_window, size_type min_periods, rolling_aggregation& agg, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef pair[unique_ptr[column], unique_ptr[column]] make_range_windows( @@ -73,7 +73,7 @@ cdef extern from "cudf/rolling.hpp" namespace "cudf" nogil: null_order null_order, range_window_type preceding, range_window_type following, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/round.pxd b/python/pylibcudf/pylibcudf/libcudf/round.pxd index 39965d025c6..f21987844f3 100644 --- a/python/pylibcudf/pylibcudf/libcudf/round.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/round.pxd @@ -6,7 +6,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -20,7 +20,7 @@ cdef extern from "cudf/round.hpp" namespace "cudf" nogil: const column_view& input, int32_t decimal_places, rounding_method method, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -28,6 +28,6 @@ cdef extern from "cudf/round.hpp" namespace "cudf" nogil: const column_view& input, int32_t decimal_places, rounding_method method, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/scalar/scalar.pxd b/python/pylibcudf/pylibcudf/libcudf/scalar/scalar.pxd index 6c3dc71e019..10d3a42c572 100644 --- a/python/pylibcudf/pylibcudf/libcudf/scalar/scalar.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/scalar/scalar.pxd @@ -8,7 +8,7 @@ from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.fixed_point.fixed_point cimport scale_type from pylibcudf.libcudf.table.table_view cimport table_view from pylibcudf.libcudf.types cimport data_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -18,31 +18,31 @@ cdef extern from "cudf/scalar/scalar.hpp" namespace "cudf" nogil: scalar(scalar other) except +libcudf_exception_handler data_type type() except +libcudf_exception_handler void set_valid_async( - bool is_valid, cuda_stream_view stream + bool is_valid, cudaStream_t stream ) except +libcudf_exception_handler - bool is_valid(cuda_stream_view stream) except +libcudf_exception_handler + bool is_valid(cudaStream_t stream) except +libcudf_exception_handler cdef cppclass numeric_scalar[T](scalar): void set_value( T value, - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler - T value(cuda_stream_view stream) except +libcudf_exception_handler + T value(cudaStream_t stream) except +libcudf_exception_handler cdef cppclass timestamp_scalar[T](scalar): void set_value( T value, - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler cdef cppclass duration_scalar[T](scalar): void set_value( T value, - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler cdef cppclass string_scalar(scalar): - string to_string(cuda_stream_view stream) except +libcudf_exception_handler + string to_string(cudaStream_t stream) except +libcudf_exception_handler cdef cppclass list_scalar(scalar): pass @@ -57,4 +57,4 @@ cdef extern from "cudf/scalar/scalar.hpp" namespace "cudf" nogil: scale_type scale, bool is_valid ) except +libcudf_exception_handler - T value(cuda_stream_view stream) except +libcudf_exception_handler + T value(cudaStream_t stream) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/scalar/scalar_factories.pxd b/python/pylibcudf/pylibcudf/libcudf/scalar/scalar_factories.pxd index 6034b2ecc08..6b1329962cd 100644 --- a/python/pylibcudf/pylibcudf/libcudf/scalar/scalar_factories.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/scalar/scalar_factories.pxd @@ -9,49 +9,49 @@ from pylibcudf.libcudf.scalar.scalar cimport scalar from pylibcudf.libcudf.fixed_point.fixed_point cimport scale_type from pylibcudf.libcudf.types cimport int128 as int128_t -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref cdef extern from "cudf/scalar/scalar_factories.hpp" namespace "cudf" nogil: cdef unique_ptr[scalar] make_string_scalar( const string & _string, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[scalar] make_fixed_width_scalar[T]( T value, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[scalar] make_fixed_point_scalar[T]( int128_t value, scale_type scale, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[scalar] make_numeric_scalar( data_type type_, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[scalar] make_timestamp_scalar( data_type type_, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[scalar] make_empty_scalar_like( const column_view &, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[scalar] make_duration_scalar( data_type type_, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[scalar] make_default_constructed_scalar( data_type type_, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/search.pxd b/python/pylibcudf/pylibcudf/libcudf/search.pxd index b369ec05392..c1e41893d2e 100644 --- a/python/pylibcudf/pylibcudf/libcudf/search.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/search.pxd @@ -7,7 +7,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.table.table_view cimport table_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -18,7 +18,7 @@ cdef extern from "cudf/search.hpp" namespace "cudf" nogil: table_view needles, vector[libcudf_types.order] column_order, vector[libcudf_types.null_order] null_precedence, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -27,13 +27,13 @@ cdef extern from "cudf/search.hpp" namespace "cudf" nogil: table_view needles, vector[libcudf_types.order] column_order, vector[libcudf_types.null_order] null_precedence, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] contains( column_view haystack, column_view needles, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/sorting.pxd b/python/pylibcudf/pylibcudf/libcudf/sorting.pxd index 97822e2c374..c8e252ced2c 100644 --- a/python/pylibcudf/pylibcudf/libcudf/sorting.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/sorting.pxd @@ -17,7 +17,7 @@ from pylibcudf.libcudf.types cimport ( null_order, size_type ) -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -26,7 +26,7 @@ cdef extern from "cudf/sorting.hpp" namespace "cudf" nogil: table_view source_table, vector[order] column_order, vector[null_order] null_precedence, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -34,7 +34,7 @@ cdef extern from "cudf/sorting.hpp" namespace "cudf" nogil: table_view source_table, vector[order] column_order, vector[null_order] null_precedence, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -45,7 +45,7 @@ cdef extern from "cudf/sorting.hpp" namespace "cudf" nogil: null_policy null_handling, null_order null_precedence, bool percentage, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -53,7 +53,7 @@ cdef extern from "cudf/sorting.hpp" namespace "cudf" nogil: const table_view& table, vector[order] column_order, vector[null_order] null_precedence, - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler cdef unique_ptr[table] segmented_sort_by_key( @@ -62,7 +62,7 @@ cdef extern from "cudf/sorting.hpp" namespace "cudf" nogil: const column_view& segment_offsets, vector[order] column_order, vector[null_order] null_precedence, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -72,7 +72,7 @@ cdef extern from "cudf/sorting.hpp" namespace "cudf" nogil: const column_view& segment_offsets, vector[order] column_order, vector[null_order] null_precedence, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -81,7 +81,7 @@ cdef extern from "cudf/sorting.hpp" namespace "cudf" nogil: const table_view& keys, vector[order] column_order, vector[null_order] null_precedence, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -90,7 +90,7 @@ cdef extern from "cudf/sorting.hpp" namespace "cudf" nogil: const table_view& keys, vector[order] column_order, vector[null_order] null_precedence, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -98,7 +98,7 @@ cdef extern from "cudf/sorting.hpp" namespace "cudf" nogil: table_view source_table, vector[order] column_order, vector[null_order] null_precedence, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -106,7 +106,7 @@ cdef extern from "cudf/sorting.hpp" namespace "cudf" nogil: table_view source_table, vector[order] column_order, vector[null_order] null_precedence, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -114,7 +114,7 @@ cdef extern from "cudf/sorting.hpp" namespace "cudf" nogil: const column_view& col, size_type k, order sort_order, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -122,6 +122,6 @@ cdef extern from "cudf/sorting.hpp" namespace "cudf" nogil: const column_view& col, size_type k, order sort_order, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/stream_compaction.pxd b/python/pylibcudf/pylibcudf/libcudf/stream_compaction.pxd index 0358aa4068c..9f8686da472 100644 --- a/python/pylibcudf/pylibcudf/libcudf/stream_compaction.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/stream_compaction.pxd @@ -14,7 +14,7 @@ from pylibcudf.libcudf.types cimport ( null_equality, size_type, ) -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -29,7 +29,7 @@ cdef extern from "cudf/stream_compaction.hpp" namespace "cudf" nogil: table_view source_table, vector[size_type] keys, size_type keep_threshold, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -37,14 +37,14 @@ cdef extern from "cudf/stream_compaction.hpp" namespace "cudf" nogil: table_view source_table, vector[size_type] keys, size_type keep_threshold, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[table] apply_boolean_mask( table_view source_table, column_view boolean_mask, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -53,7 +53,7 @@ cdef extern from "cudf/stream_compaction.hpp" namespace "cudf" nogil: vector[size_type] keys, duplicate_keep_option keep, null_equality nulls_equal, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -63,7 +63,7 @@ cdef extern from "cudf/stream_compaction.hpp" namespace "cudf" nogil: duplicate_keep_option keep, null_equality nulls_equal, nan_equality nans_equals, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -72,7 +72,7 @@ cdef extern from "cudf/stream_compaction.hpp" namespace "cudf" nogil: duplicate_keep_option keep, null_equality nulls_equal, nan_equality nans_equal, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -82,7 +82,7 @@ cdef extern from "cudf/stream_compaction.hpp" namespace "cudf" nogil: duplicate_keep_option keep, null_equality nulls_equal, nan_equality nans_equal, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -90,6 +90,6 @@ cdef extern from "cudf/stream_compaction.hpp" namespace "cudf" nogil: table_view predicate_table, const expression& predicate_expr, table_view filter_table, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/attributes.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/attributes.pxd index 06e95c95870..0cee9e43346 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/attributes.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/attributes.pxd @@ -4,7 +4,7 @@ from libcpp.memory cimport unique_ptr from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -12,15 +12,15 @@ cdef extern from "cudf/strings/attributes.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] count_characters( column_view source_strings, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] count_bytes( column_view source_strings, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] code_points( column_view source_strings, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/capitalize.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/capitalize.pxd index b615cd984db..7b8ac094311 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/capitalize.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/capitalize.pxd @@ -6,7 +6,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport string_scalar from pylibcudf.libcudf.strings.char_types cimport string_character_types -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -14,18 +14,18 @@ cdef extern from "cudf/strings/capitalize.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] capitalize( const column_view & strings, const string_scalar & delimiters, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] title( const column_view & strings, string_character_types sequence_type, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] is_title( const column_view & strings, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/case.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/case.pxd index 463586d9f37..a056f1b4737 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/case.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/case.pxd @@ -4,22 +4,22 @@ from libcpp.memory cimport unique_ptr from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref cdef extern from "cudf/strings/case.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] to_lower( const column_view & strings, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] to_upper( const column_view & strings, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] swapcase( const column_view & strings, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/char_types.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/char_types.pxd index 7706498eceb..c6af0fb73d2 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/char_types.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/char_types.pxd @@ -6,7 +6,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport string_scalar -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -29,7 +29,7 @@ cdef extern from "cudf/strings/char_types/char_types.hpp" \ column_view source_strings, string_character_types types, string_character_types verify_types, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] filter_characters_of_type( @@ -37,5 +37,5 @@ cdef extern from "cudf/strings/char_types/char_types.hpp" \ string_character_types types_to_remove, string_scalar replacement, string_character_types types_to_keep, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/combine.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/combine.pxd index ef831d3b167..2e2b6656797 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/combine.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/combine.pxd @@ -8,7 +8,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport string_scalar from pylibcudf.libcudf.table.table_view cimport table_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -27,7 +27,7 @@ cdef extern from "cudf/strings/combine.hpp" namespace "cudf::strings" nogil: string_scalar separator, string_scalar narep, separator_on_nulls separate_nulls, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] concatenate( @@ -36,14 +36,14 @@ cdef extern from "cudf/strings/combine.hpp" namespace "cudf::strings" nogil: string_scalar separator_narep, string_scalar col_narep, separator_on_nulls separate_nulls, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] join_strings( column_view input, string_scalar separator, string_scalar narep, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] join_list_elements( @@ -53,7 +53,7 @@ cdef extern from "cudf/strings/combine.hpp" namespace "cudf::strings" nogil: string_scalar string_narep, separator_on_nulls separate_nulls, output_if_empty_list empty_list_policy, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] join_list_elements( @@ -62,5 +62,5 @@ cdef extern from "cudf/strings/combine.hpp" namespace "cudf::strings" nogil: string_scalar narep, separator_on_nulls separate_nulls, output_if_empty_list empty_list_policy, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/contains.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/contains.pxd index f60782e93b7..cc9a7c6835d 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/contains.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/contains.pxd @@ -7,7 +7,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport string_scalar from pylibcudf.libcudf.strings.regex_program cimport regex_program -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -16,31 +16,31 @@ cdef extern from "cudf/strings/contains.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] contains_re( column_view source_strings, regex_program, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] count_re( column_view source_strings, regex_program, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] matches_re( column_view source_strings, regex_program, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] like( column_view source_strings, string pattern, string escape_character, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] like( column_view source_strings, column_view patterns, string_scalar escape_character, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_booleans.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_booleans.pxd index b5b837878f9..8875bc62ed5 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_booleans.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_booleans.pxd @@ -6,7 +6,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport string_scalar -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -15,12 +15,12 @@ cdef extern from "cudf/strings/convert/convert_booleans.hpp" namespace \ cdef unique_ptr[column] to_booleans( column_view input, string_scalar true_string, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] from_booleans( column_view booleans, string_scalar true_string, string_scalar false_string, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_datetime.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_datetime.pxd index 5779839a685..92983f9dc49 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_datetime.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_datetime.pxd @@ -7,7 +7,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.types cimport data_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -17,18 +17,18 @@ cdef extern from "cudf/strings/convert/convert_datetime.hpp" namespace \ column_view input, data_type timestamp_type, string format, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] from_timestamps( column_view timestamps, string format, column_view names, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] is_timestamp( column_view input_col, string format, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_durations.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_durations.pxd index 2eae8b987b9..4f22b715ef9 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_durations.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_durations.pxd @@ -7,7 +7,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.types cimport data_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -17,11 +17,11 @@ cdef extern from "cudf/strings/convert/convert_durations.hpp" namespace \ const column_view & input, data_type duration_type, const string & format, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] from_durations( const column_view & durations, const string & format, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_fixed_point.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_fixed_point.pxd index e5f512c331f..8aaa0ebf4c7 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_fixed_point.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_fixed_point.pxd @@ -6,7 +6,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.types cimport data_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -15,17 +15,17 @@ cdef extern from "cudf/strings/convert/convert_fixed_point.hpp" namespace \ cdef unique_ptr[column] to_fixed_point( column_view input, data_type output_type, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] from_fixed_point( column_view input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] is_fixed_point( column_view input, data_type decimal_type, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_floats.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_floats.pxd index 4ea1cd527f4..5a111c1979d 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_floats.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_floats.pxd @@ -6,7 +6,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.types cimport data_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -15,16 +15,16 @@ cdef extern from "cudf/strings/convert/convert_floats.hpp" namespace \ cdef unique_ptr[column] to_floats( column_view strings, data_type output_type, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] from_floats( column_view floats, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] is_float( column_view input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_integers.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_integers.pxd index 306c4b66758..4d3f4ff758a 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_integers.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_integers.pxd @@ -6,7 +6,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.types cimport data_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -15,40 +15,40 @@ cdef extern from "cudf/strings/convert/convert_integers.hpp" namespace \ cdef unique_ptr[column] to_integers( column_view input, data_type output_type, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] from_integers( column_view integers, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] is_integer( column_view input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] is_integer( column_view input, data_type int_type, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] hex_to_integers( column_view input, data_type output_type, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] is_hex( column_view input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] integers_to_hex( column_view input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_ipv4.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_ipv4.pxd index d12f3992d85..00a64787957 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_ipv4.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_ipv4.pxd @@ -5,7 +5,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -13,16 +13,16 @@ cdef extern from "cudf/strings/convert/convert_ipv4.hpp" namespace \ "cudf::strings" nogil: cdef unique_ptr[column] ipv4_to_integers( column_view input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] integers_to_ipv4( column_view integers, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] is_ipv4( column_view input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_lists.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_lists.pxd index 8ed381e87da..bfae49bae4b 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_lists.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_lists.pxd @@ -6,7 +6,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport string_scalar -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -17,5 +17,5 @@ cdef extern from "cudf/strings/convert/convert_lists.hpp" namespace \ column_view input, string_scalar na_rep, column_view separators, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_urls.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_urls.pxd index b20c03f976b..db2d4f4efc0 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_urls.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/convert/convert_urls.pxd @@ -5,7 +5,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -13,10 +13,10 @@ cdef extern from "cudf/strings/convert/convert_urls.hpp" namespace \ "cudf::strings" nogil: cdef unique_ptr[column] url_encode( column_view input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] url_decode( column_view input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/extract.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/extract.pxd index 845de206dbf..d3e0d0fd35a 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/extract.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/extract.pxd @@ -7,7 +7,7 @@ from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.strings.regex_program cimport regex_program from pylibcudf.libcudf.table.table cimport table from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -16,18 +16,18 @@ cdef extern from "cudf/strings/extract.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[table] extract( column_view input, regex_program prog, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] extract_all_record( column_view input, regex_program prog, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] extract_single( column_view input, regex_program prog, size_type group, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/find.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/find.pxd index b8934aeb7fe..42752152de8 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/find.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/find.pxd @@ -7,7 +7,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport string_scalar from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -16,37 +16,37 @@ cdef extern from "cudf/strings/find.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] contains( column_view source_strings, string_scalar target, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] contains( column_view source_strings, column_view target_strings, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] ends_with( column_view source_strings, string_scalar target, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] ends_with( column_view source_strings, column_view target_strings, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] starts_with( column_view source_strings, string_scalar target, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] starts_with( column_view source_strings, column_view target_strings, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] find( @@ -54,14 +54,14 @@ cdef extern from "cudf/strings/find.hpp" namespace "cudf::strings" nogil: string_scalar target, size_type start, size_type stop, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] find( column_view source_strings, column_view target, size_type start, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] rfind( @@ -69,5 +69,5 @@ cdef extern from "cudf/strings/find.hpp" namespace "cudf::strings" nogil: string_scalar target, size_type start, size_type stop, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/find_multiple.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/find_multiple.pxd index da751990053..1e42a476c13 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/find_multiple.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/find_multiple.pxd @@ -5,7 +5,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.table.table cimport table -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -15,11 +15,11 @@ cdef extern from "cudf/strings/find_multiple.hpp" namespace "cudf::strings" \ cdef unique_ptr[table] contains_multiple( column_view input, column_view targets, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] find_multiple( column_view input, column_view targets, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/findall.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/findall.pxd index 02ecbef7095..d72ffd09d8e 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/findall.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/findall.pxd @@ -5,7 +5,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.strings.regex_program cimport regex_program -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -14,11 +14,11 @@ cdef extern from "cudf/strings/findall.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] findall( column_view input, regex_program prog, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] find_re( column_view input, regex_program prog, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/padding.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/padding.pxd index 5e3e5c43f61..8b291a22a05 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/padding.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/padding.pxd @@ -9,7 +9,7 @@ from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport string_scalar from pylibcudf.libcudf.strings.side_type cimport side_type from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -20,17 +20,17 @@ cdef extern from "cudf/strings/padding.hpp" namespace "cudf::strings" nogil: size_type width, side_type side, string fill_char, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] zfill( column_view input, size_type width, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] zfill_by_widths( column_view input, column_view widths, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/repeat.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/repeat.pxd index 05a2954af35..86519de0b90 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/repeat.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/repeat.pxd @@ -6,7 +6,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -16,13 +16,13 @@ cdef extern from "cudf/strings/repeat_strings.hpp" namespace "cudf::strings" \ cdef unique_ptr[column] repeat_strings( column_view input, size_type repeat_times, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] repeat_strings( column_view input, column_view repeat_times, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/replace.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/replace.pxd index 263b91475b8..cf2573af5ed 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/replace.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/replace.pxd @@ -8,7 +8,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport string_scalar from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -18,7 +18,7 @@ cdef extern from "cudf/strings/replace.hpp" namespace "cudf::strings" nogil: string_scalar repl, size_type start, size_type stop, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] replace( @@ -26,12 +26,12 @@ cdef extern from "cudf/strings/replace.hpp" namespace "cudf::strings" nogil: string_scalar target, string_scalar repl, int32_t maxrepl, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] replace_multiple( column_view source_strings, column_view target_strings, column_view repl_strings, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/replace_re.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/replace_re.pxd index 5f5cbaeaf55..d3e958841ab 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/replace_re.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/replace_re.pxd @@ -11,7 +11,7 @@ from pylibcudf.libcudf.strings.regex_flags cimport regex_flags from pylibcudf.libcudf.strings.regex_program cimport regex_program from pylibcudf.libcudf.table.table cimport table from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -22,7 +22,7 @@ cdef extern from "cudf/strings/replace_re.hpp" namespace "cudf::strings" nogil: regex_program prog, string_scalar replacement, size_type max_replace_count, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] replace_re( @@ -30,12 +30,12 @@ cdef extern from "cudf/strings/replace_re.hpp" namespace "cudf::strings" nogil: vector[string] patterns, column_view replacements, regex_flags flags, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] replace_with_backrefs( column_view input, regex_program prog, string replacement, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/reverse.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/reverse.pxd index 6e6fc2acac4..39a3ac4b769 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/reverse.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/reverse.pxd @@ -4,12 +4,12 @@ from libcpp.memory cimport unique_ptr from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref cdef extern from "cudf/strings/reverse.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] reverse( column_view source_strings, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/split/partition.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/split/partition.pxd index 0c99455ea33..6c9031482ca 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/split/partition.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/split/partition.pxd @@ -7,7 +7,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport string_scalar from pylibcudf.libcudf.table.table cimport table -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -17,11 +17,11 @@ cdef extern from "cudf/strings/split/partition.hpp" namespace \ cdef unique_ptr[table] partition( column_view input, string_scalar delimiter, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[table] rpartition( column_view input, string_scalar delimiter, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/split/split.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/split/split.pxd index 9ed741b608a..5d14fefdb1b 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/split/split.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/split/split.pxd @@ -9,7 +9,7 @@ from pylibcudf.libcudf.scalar.scalar cimport string_scalar from pylibcudf.libcudf.strings.regex_program cimport regex_program from pylibcudf.libcudf.table.table cimport table from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -20,35 +20,35 @@ cdef extern from "cudf/strings/split/split.hpp" namespace \ column_view strings_column, string_scalar delimiter, size_type maxsplit, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[table] rsplit( column_view strings_column, string_scalar delimiter, size_type maxsplit, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] split_record( column_view strings, string_scalar delimiter, size_type maxsplit, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] rsplit_record( column_view strings, string_scalar delimiter, size_type maxsplit, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] split_part( column_view strings, string_scalar delimiter, size_type index, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler @@ -59,26 +59,26 @@ cdef extern from "cudf/strings/split/split_re.hpp" namespace \ const column_view& input, regex_program prog, size_type maxsplit, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[table] rsplit_re( const column_view& input, regex_program prog, size_type maxsplit, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] split_record_re( const column_view& input, regex_program prog, size_type maxsplit, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef unique_ptr[column] rsplit_record_re( const column_view& input, regex_program prog, size_type maxsplit, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/strings_column_view.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/strings_column_view.pxd index 8c72fed7219..5fa0dfb4289 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/strings_column_view.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/strings_column_view.pxd @@ -1,13 +1,13 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libc.stdint cimport int64_t from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column_view cimport column_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t cdef extern from "cudf/strings/strings_column_view.hpp" namespace "cudf" nogil: cdef cppclass strings_column_view: strings_column_view(column_view) except +libcudf_exception_handler - int64_t chars_size(cuda_stream_view) except +libcudf_exception_handler + int64_t chars_size(cudaStream_t) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/strip.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/strip.pxd index 13e017c33f7..4d56b2de5d3 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/strip.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/strip.pxd @@ -6,7 +6,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport string_scalar from pylibcudf.libcudf.strings.side_type cimport side_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -16,5 +16,5 @@ cdef extern from "cudf/strings/strip.hpp" namespace "cudf::strings" nogil: column_view input, side_type side, string_scalar to_strip, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/substring.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/substring.pxd index 21c2fe4a77b..d0b4f192307 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/substring.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/substring.pxd @@ -7,7 +7,7 @@ from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport numeric_scalar from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -17,7 +17,7 @@ cdef extern from "cudf/strings/slice.hpp" namespace "cudf::strings" nogil: numeric_scalar[size_type] start, numeric_scalar[size_type] end, numeric_scalar[size_type] step, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -25,6 +25,6 @@ cdef extern from "cudf/strings/slice.hpp" namespace "cudf::strings" nogil: column_view source_strings, column_view starts, column_view stops, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/translate.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/translate.pxd index 9bdc0489a89..dcf5aa20948 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/translate.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/translate.pxd @@ -9,7 +9,7 @@ from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.scalar.scalar cimport string_scalar from pylibcudf.libcudf.types cimport char_utf8 -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -18,7 +18,7 @@ cdef extern from "cudf/strings/translate.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] translate( column_view input, vector[pair[char_utf8, char_utf8]] chars_table, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -31,5 +31,5 @@ cdef extern from "cudf/strings/translate.hpp" namespace "cudf::strings" nogil: vector[pair[char_utf8, char_utf8]] characters_to_filter, filter_type keep_characters, string_scalar replacement, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/strings/wrap.pxd b/python/pylibcudf/pylibcudf/libcudf/strings/wrap.pxd index 8aa5631a12e..2ddd924df48 100644 --- a/python/pylibcudf/pylibcudf/libcudf/strings/wrap.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/strings/wrap.pxd @@ -5,7 +5,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -14,5 +14,5 @@ cdef extern from "cudf/strings/wrap.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] wrap( column_view input, size_type width, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/structs/structs_column_view.pxd b/python/pylibcudf/pylibcudf/libcudf/structs/structs_column_view.pxd index 7b339782295..d51a51dfb13 100644 --- a/python/pylibcudf/pylibcudf/libcudf/structs/structs_column_view.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/structs/structs_column_view.pxd @@ -1,6 +1,6 @@ # SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column_view cimport column_view @@ -22,5 +22,5 @@ cdef extern from "cudf/structs/structs_column_view.hpp" namespace "cudf" nogil: column_view parent() except +libcudf_exception_handler column_view get_sliced_child( size_type index, - cuda_stream_view stream + cudaStream_t stream ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/table/table.pxd b/python/pylibcudf/pylibcudf/libcudf/table/table.pxd index 230131d5520..dcfc046a904 100644 --- a/python/pylibcudf/pylibcudf/libcudf/table/table.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/table/table.pxd @@ -6,7 +6,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.table.table_view cimport mutable_table_view, table_view from pylibcudf.libcudf.types cimport size_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -14,12 +14,12 @@ cdef extern from "cudf/table/table.hpp" namespace "cudf" nogil: cdef cppclass table: table( const table&, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler table( table_view, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler size_type num_columns() except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/transform.pxd b/python/pylibcudf/pylibcudf/libcudf/transform.pxd index 9b2ace2d940..ebc9d8bfa1d 100644 --- a/python/pylibcudf/pylibcudf/libcudf/transform.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/transform.pxd @@ -16,14 +16,14 @@ from pylibcudf.libcudf.types cimport bitmask_type, data_type, size_type from pylibcudf.libcudf.types cimport null_aware, output_nullability from rmm.librmm.device_buffer cimport device_buffer -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref cdef extern from "cudf/transform.hpp" namespace "cudf" nogil: cdef pair[unique_ptr[device_buffer], size_type] bools_to_mask ( const column_view& input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -31,19 +31,19 @@ cdef extern from "cudf/transform.hpp" namespace "cudf" nogil: const bitmask_type* bitmask, size_type begin_bit, size_type end_bit, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef pair[unique_ptr[device_buffer], size_type] nans_to_nulls( const column_view& input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] column_nans_to_nulls( const column_view& input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler @@ -55,33 +55,33 @@ cdef extern from "cudf/transform.hpp" namespace "cudf" nogil: optional[void *] user_data, null_aware is_null_aware, output_nullability null_policy, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef pair[unique_ptr[table], unique_ptr[column]] encode( table_view input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef pair[unique_ptr[column], table_view] one_hot_encode( column_view input_column, column_view categories, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] compute_column( const table_view table, const expression& expr, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef unique_ptr[column] compute_column_jit( const table_view table, const expression& expr, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/transpose.pxd b/python/pylibcudf/pylibcudf/libcudf/transpose.pxd index 2345ab5a2d9..0ce2048ba0f 100644 --- a/python/pylibcudf/pylibcudf/libcudf/transpose.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/transpose.pxd @@ -6,7 +6,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.table.table_view cimport table_view -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -16,6 +16,6 @@ cdef extern from "cudf/transpose.hpp" namespace "cudf" nogil: table_view ] transpose( table_view input_table, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/unary.pxd b/python/pylibcudf/pylibcudf/libcudf/unary.pxd index d3fd2f2f976..6f59ff8d5e0 100644 --- a/python/pylibcudf/pylibcudf/libcudf/unary.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/unary.pxd @@ -7,7 +7,7 @@ from pylibcudf.exception_handler cimport libcudf_exception_handler from pylibcudf.libcudf.column.column cimport column from pylibcudf.libcudf.column.column_view cimport column_view from pylibcudf.libcudf.types cimport data_type -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t from rmm.librmm.memory_resource cimport device_async_resource_ref @@ -42,32 +42,32 @@ cdef extern from "cudf/unary.hpp" namespace "cudf" nogil: cdef extern unique_ptr[column] unary_operation( column_view input, unary_operator op, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef extern unique_ptr[column] is_null( column_view input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef extern unique_ptr[column] is_valid( column_view input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef extern unique_ptr[column] cast( column_view input, data_type out_type, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr) except +libcudf_exception_handler cdef extern bool is_supported_cast(data_type from_, data_type to) noexcept cdef extern unique_ptr[column] is_nan( column_view input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler cdef extern unique_ptr[column] is_not_nan( column_view input, - cuda_stream_view stream, + cudaStream_t stream, device_async_resource_ref mr ) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/unique_count.pxd b/python/pylibcudf/pylibcudf/libcudf/unique_count.pxd index 5954dace85e..04001f5a064 100644 --- a/python/pylibcudf/pylibcudf/libcudf/unique_count.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/unique_count.pxd @@ -9,7 +9,7 @@ from pylibcudf.libcudf.types cimport ( null_policy, size_type, ) -from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from cuda.bindings.cyruntime cimport cudaStream_t cdef extern from "cudf/reduction/unique_count.hpp" namespace "cudf" nogil: @@ -17,9 +17,9 @@ cdef extern from "cudf/reduction/unique_count.hpp" namespace "cudf" nogil: column_view column, null_policy null_handling, nan_policy nan_handling, - cuda_stream_view stream) except +libcudf_exception_handler + cudaStream_t stream) except +libcudf_exception_handler cdef size_type unique_count( table_view source_table, null_equality nulls_equal, - cuda_stream_view stream) except +libcudf_exception_handler + cudaStream_t stream) except +libcudf_exception_handler diff --git a/python/pylibcudf/pylibcudf/libcudf/utilities/default_stream.pxd b/python/pylibcudf/pylibcudf/libcudf/utilities/default_stream.pxd index a9569f11706..661db24f5aa 100644 --- a/python/pylibcudf/pylibcudf/libcudf/utilities/default_stream.pxd +++ b/python/pylibcudf/pylibcudf/libcudf/utilities/default_stream.pxd @@ -1,10 +1,9 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 +from cuda.bindings.cyruntime cimport cudaStream_t from libcpp cimport bool -from rmm.librmm.cuda_stream_view cimport cuda_stream_view - cdef extern from "cudf/utilities/default_stream.hpp" namespace "cudf" nogil: cdef bool is_ptds_enabled() - cdef cuda_stream_view get_default_stream() + cdef cudaStream_t get_default_stream() diff --git a/python/pylibcudf/pylibcudf/lists.pxd b/python/pylibcudf/pylibcudf/lists.pxd index be47db18a59..88b09c01531 100644 --- a/python/pylibcudf/pylibcudf/lists.pxd +++ b/python/pylibcudf/pylibcudf/lists.pxd @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp cimport bool @@ -9,7 +9,6 @@ from pylibcudf.libcudf.copying cimport out_of_bounds_policy from pylibcudf.libcudf.lists.combine cimport concatenate_null_policy from pylibcudf.libcudf.lists.contains cimport duplicate_find_option from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream from .column cimport Column from .scalar cimport Scalar @@ -26,33 +25,33 @@ ctypedef fused ColumnOrSizeType: cpdef Table explode_outer( Table, size_type explode_column_idx, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef Column concatenate_rows( Table, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef Column concatenate_list_elements( Column, concatenate_null_policy null_policy, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef Column contains( Column, ColumnOrScalar, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef Column contains_nulls( Column, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -60,13 +59,13 @@ cpdef Column index_of( Column, ColumnOrScalar, duplicate_find_option, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef Column reverse( Column, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -74,20 +73,20 @@ cpdef Column segmented_gather( Column, Column, out_of_bounds_policy bounds_policy=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef Column extract_list_element( Column, ColumnOrSizeType, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef Column count_elements( Column, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -95,7 +94,7 @@ cpdef Column sequences( Column, Column, Column steps = *, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -104,7 +103,7 @@ cpdef Column sort_lists( order, null_order, bool stable = *, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -113,7 +112,7 @@ cpdef Column difference_distinct( Column, null_equality nulls_equal=*, nan_equality nans_equal=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -122,7 +121,7 @@ cpdef Column have_overlap( Column, null_equality nulls_equal=*, nan_equality nans_equal=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -131,7 +130,7 @@ cpdef Column intersect_distinct( Column, null_equality nulls_equal=*, nan_equality nans_equal=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -140,14 +139,14 @@ cpdef Column union_distinct( Column, null_equality nulls_equal=*, nan_equality nans_equal=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef Column apply_boolean_mask( Column, Column, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -155,6 +154,6 @@ cpdef Column distinct( Column, null_equality, nan_equality, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) diff --git a/python/pylibcudf/pylibcudf/lists.pyi b/python/pylibcudf/pylibcudf/lists.pyi index a3bcf9f76d6..1e418b59726 100644 --- a/python/pylibcudf/pylibcudf/lists.pyi +++ b/python/pylibcudf/pylibcudf/lists.pyi @@ -1,16 +1,16 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from enum import IntEnum from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.copying import OutOfBoundsPolicy from pylibcudf.scalar import Scalar from pylibcudf.table import Table from pylibcudf.types import NanEquality, NullEquality, NullOrder, Order +from pylibcudf.utils import CudaStreamLike class ConcatenateNullPolicy(IntEnum): IGNORE = ... @@ -23,66 +23,66 @@ class DuplicateFindOption(IntEnum): def explode_outer( input: Table, explode_column_idx: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def concatenate_rows( input: Table, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def concatenate_list_elements( input: Column, null_policy: ConcatenateNullPolicy, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def contains( input: Column, search_key: Column | Scalar, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def contains_nulls( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def index_of( input: Column, search_key: Column | Scalar, find_option: DuplicateFindOption, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def reverse( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def segmented_gather( input: Column, gather_map_list: Column, bounds_policy: OutOfBoundsPolicy = OutOfBoundsPolicy.DONT_CHECK, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def extract_list_element( input: Column, index: Column | int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def count_elements( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def sequences( starts: Column, sizes: Column, steps: Column | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def sort_lists( @@ -90,7 +90,7 @@ def sort_lists( sort_order: Order, na_position: NullOrder, stable: bool = False, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def difference_distinct( @@ -98,7 +98,7 @@ def difference_distinct( rhs: Column, nulls_equal: NullEquality = NullEquality.EQUAL, nans_equal: NanEquality = NanEquality.ALL_EQUAL, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def have_overlap( @@ -106,7 +106,7 @@ def have_overlap( rhs: Column, nulls_equal: NullEquality = NullEquality.EQUAL, nans_equal: NanEquality = NanEquality.ALL_EQUAL, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def intersect_distinct( @@ -114,7 +114,7 @@ def intersect_distinct( rhs: Column, nulls_equal: NullEquality = NullEquality.EQUAL, nans_equal: NanEquality = NanEquality.ALL_EQUAL, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def union_distinct( @@ -122,19 +122,19 @@ def union_distinct( rhs: Column, nulls_equal: NullEquality = NullEquality.EQUAL, nans_equal: NanEquality = NanEquality.ALL_EQUAL, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def apply_boolean_mask( input: Column, boolean_mask: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def distinct( input: Column, nulls_equal: NullEquality, nans_equal: NanEquality, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/lists.pyx b/python/pylibcudf/pylibcudf/lists.pyx index 0076f7da677..fd05242e44f 100644 --- a/python/pylibcudf/pylibcudf/lists.pyx +++ b/python/pylibcudf/pylibcudf/lists.pyx @@ -55,6 +55,7 @@ from .column cimport Column, ListsColumnView from .scalar cimport Scalar from .table cimport Table from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "ConcatenateNullPolicy", @@ -82,7 +83,7 @@ __all__ = [ cpdef Table explode_outer( Table input, size_type explode_column_idx, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Explode a column of lists into rows. @@ -105,20 +106,21 @@ cpdef Table explode_outer( """ cdef unique_ptr[table] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_explode.explode_outer( - input.view(), explode_column_idx, stream.view(), mr.get_mr() + input.view(), explode_column_idx, _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef Column concatenate_rows( Table input, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Concatenate multiple lists columns into a single lists column row-wise. @@ -139,21 +141,22 @@ cpdef Column concatenate_rows( """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_concatenate_rows( - input.view(), concatenate_null_policy.IGNORE, stream.view(), mr.get_mr() + input.view(), concatenate_null_policy.IGNORE, _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column concatenate_list_elements( Column input, concatenate_null_policy null_policy, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Concatenate multiple lists on the same row into a single list. @@ -174,21 +177,22 @@ cpdef Column concatenate_list_elements( """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_concatenate_list_elements( - input.view(), null_policy, stream.view(), mr.get_mr() + input.view(), null_policy, _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column contains( Column input, ColumnOrScalar search_key, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Create a column of bool values indicating whether @@ -218,7 +222,8 @@ cpdef Column contains( cdef unique_ptr[column] c_result cdef ListsColumnView list_view = input.list_view() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if not isinstance(search_key, (Column, Scalar)): @@ -230,15 +235,15 @@ cpdef Column contains( search_key.view() if ColumnOrScalar is Column else dereference( search_key.get() ), - stream.view(), + _cs, mr.get_mr(), ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column contains_nulls( Column input, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Create a column of bool values indicating whether @@ -262,21 +267,22 @@ cpdef Column contains_nulls( cdef unique_ptr[column] c_result cdef ListsColumnView list_view = input.list_view() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_contains.contains_nulls( - list_view.view(), stream.view(), mr.get_mr() + list_view.view(), _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column index_of( Column input, ColumnOrScalar search_key, duplicate_find_option find_option, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Create a column of index values indicating the position of a search @@ -307,7 +313,8 @@ cpdef Column index_of( cdef unique_ptr[column] c_result cdef ListsColumnView list_view = input.list_view() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -317,15 +324,15 @@ cpdef Column index_of( search_key.get() ), find_option, - stream.view(), + _cs, mr.get_mr(), ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column reverse( Column input, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Reverse the element order within each list of the input column. @@ -347,19 +354,20 @@ cpdef Column reverse( cdef unique_ptr[column] c_result cdef ListsColumnView list_view = input.list_view() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_reverse.reverse(list_view.view(), stream.view(), mr.get_mr()) - return Column.from_libcudf(move(c_result), stream, mr) + c_result = cpp_reverse.reverse(list_view.view(), _cs, mr.get_mr()) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column segmented_gather( Column input, Column gather_map_list, out_of_bounds_policy bounds_policy=out_of_bounds_policy.DONT_CHECK, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Create a column with elements gathered based on the indices in gather_map_list @@ -394,7 +402,8 @@ cpdef Column segmented_gather( cdef ListsColumnView list_view1 = input.list_view() cdef ListsColumnView list_view2 = gather_map_list.list_view() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -402,16 +411,16 @@ cpdef Column segmented_gather( list_view1.view(), list_view2.view(), bounds_policy, - stream.view(), + _cs, mr.get_mr(), ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column extract_list_element( Column input, ColumnOrSizeType index, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Create a column of extracted list elements. @@ -433,22 +442,23 @@ cpdef Column extract_list_element( cdef unique_ptr[column] c_result cdef ListsColumnView list_view = input.list_view() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_extract_list_element( list_view.view(), index.view() if ColumnOrSizeType is Column else index, - stream.view(), + _cs, mr.get_mr(), ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column count_elements( Column input, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Count the number of rows in each @@ -472,20 +482,21 @@ cpdef Column count_elements( cdef ListsColumnView list_view = input.list_view() cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_count_elements(list_view.view(), stream.view(), mr.get_mr()) + c_result = cpp_count_elements(list_view.view(), _cs, mr.get_mr()) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column sequences( Column starts, Column sizes, Column steps = None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Create a lists column in which each row contains a sequence of @@ -509,7 +520,8 @@ cpdef Column sequences( """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if steps is not None: @@ -518,22 +530,22 @@ cpdef Column sequences( starts.view(), steps.view(), sizes.view(), - stream.view(), + _cs, mr.get_mr(), ) else: with nogil: c_result = cpp_filling.sequences( - starts.view(), sizes.view(), stream.view(), mr.get_mr() + starts.view(), sizes.view(), _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column sort_lists( Column input, order sort_order, null_order na_position, bool stable = False, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Sort the elements within a list in each row of a list column. @@ -561,7 +573,8 @@ cpdef Column sort_lists( cdef unique_ptr[column] c_result cdef ListsColumnView list_view = input.list_view() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -570,7 +583,7 @@ cpdef Column sort_lists( list_view.view(), sort_order, na_position, - stream.view(), + _cs, mr.get_mr(), ) else: @@ -578,10 +591,10 @@ cpdef Column sort_lists( list_view.view(), sort_order, na_position, - stream.view(), + _cs, mr.get_mr(), ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column difference_distinct( @@ -589,7 +602,7 @@ cpdef Column difference_distinct( Column rhs, null_equality nulls_equal=null_equality.EQUAL, nan_equality nans_equal=nan_equality.ALL_EQUAL, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Create a column of index values indicating the position of a search @@ -617,7 +630,8 @@ cpdef Column difference_distinct( cdef ListsColumnView lhs_view = lhs.list_view() cdef ListsColumnView rhs_view = rhs.list_view() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -626,10 +640,10 @@ cpdef Column difference_distinct( rhs_view.view(), nulls_equal, nans_equal, - stream.view(), + _cs, mr.get_mr(), ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column have_overlap( @@ -637,7 +651,7 @@ cpdef Column have_overlap( Column rhs, null_equality nulls_equal=null_equality.EQUAL, nan_equality nans_equal=nan_equality.ALL_EQUAL, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Check if lists at each row of the given lists columns overlap. @@ -664,7 +678,8 @@ cpdef Column have_overlap( cdef ListsColumnView lhs_view = lhs.list_view() cdef ListsColumnView rhs_view = rhs.list_view() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -673,10 +688,10 @@ cpdef Column have_overlap( rhs_view.view(), nulls_equal, nans_equal, - stream.view(), + _cs, mr.get_mr(), ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column intersect_distinct( @@ -684,7 +699,7 @@ cpdef Column intersect_distinct( Column rhs, null_equality nulls_equal=null_equality.EQUAL, nan_equality nans_equal=nan_equality.ALL_EQUAL, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Create a lists column of distinct elements common to two input lists columns. @@ -711,7 +726,8 @@ cpdef Column intersect_distinct( cdef ListsColumnView lhs_view = lhs.list_view() cdef ListsColumnView rhs_view = rhs.list_view() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -720,10 +736,10 @@ cpdef Column intersect_distinct( rhs_view.view(), nulls_equal, nans_equal, - stream.view(), + _cs, mr.get_mr(), ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column union_distinct( @@ -731,7 +747,7 @@ cpdef Column union_distinct( Column rhs, null_equality nulls_equal=null_equality.EQUAL, nan_equality nans_equal=nan_equality.ALL_EQUAL, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Create a lists column of distinct elements found in @@ -759,7 +775,8 @@ cpdef Column union_distinct( cdef ListsColumnView lhs_view = lhs.list_view() cdef ListsColumnView rhs_view = rhs.list_view() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -768,16 +785,16 @@ cpdef Column union_distinct( rhs_view.view(), nulls_equal, nans_equal, - stream.view(), + _cs, mr.get_mr(), ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column apply_boolean_mask( Column input, Column boolean_mask, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Filters elements in each row of the input lists column using a boolean mask @@ -802,24 +819,25 @@ cpdef Column apply_boolean_mask( cdef ListsColumnView list_view = input.list_view() cdef ListsColumnView mask_view = boolean_mask.list_view() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_apply_boolean_mask( list_view.view(), mask_view.view(), - stream.view(), + _cs, mr.get_mr(), ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column distinct( Column input, null_equality nulls_equal, nan_equality nans_equal, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Create a new list column without duplicate elements in each list. @@ -843,7 +861,8 @@ cpdef Column distinct( cdef unique_ptr[column] c_result cdef ListsColumnView list_view = input.list_view() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -852,10 +871,10 @@ cpdef Column distinct( nulls_equal, nans_equal, duplicate_keep_option.KEEP_ANY, - stream.view(), + _cs, mr.get_mr(), ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) ConcatenateNullPolicy.__str__ = ConcatenateNullPolicy.__repr__ DuplicateFindOption.__str__ = DuplicateFindOption.__repr__ diff --git a/python/pylibcudf/pylibcudf/merge.pxd b/python/pylibcudf/pylibcudf/merge.pxd index aed9dda7479..07624852289 100644 --- a/python/pylibcudf/pylibcudf/merge.pxd +++ b/python/pylibcudf/pylibcudf/merge.pxd @@ -1,9 +1,8 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from .table cimport Table -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource @@ -12,6 +11,6 @@ cpdef Table merge ( list key_cols, list column_order, list null_precedence, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/merge.pyi b/python/pylibcudf/pylibcudf/merge.pyi index f96e1d8534e..50e87d5bffa 100644 --- a/python/pylibcudf/pylibcudf/merge.pyi +++ b/python/pylibcudf/pylibcudf/merge.pyi @@ -1,17 +1,17 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.table import Table from pylibcudf.types import NullOrder, Order +from pylibcudf.utils import CudaStreamLike def merge( tables_to_merge: list[Table], key_cols: list[int], column_order: list[Order], null_precedence: list[NullOrder], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... diff --git a/python/pylibcudf/pylibcudf/merge.pyx b/python/pylibcudf/pylibcudf/merge.pyx index a6cbaf81051..3c0cd93a342 100644 --- a/python/pylibcudf/pylibcudf/merge.pyx +++ b/python/pylibcudf/pylibcudf/merge.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -14,6 +14,7 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from .table cimport Table from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["merge"] @@ -22,7 +23,7 @@ cpdef Table merge ( list key_cols, list column_order, list null_precedence, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Merge a set of sorted tables. @@ -58,7 +59,8 @@ cpdef Table merge ( c_tables_to_merge.push_back(( tbl).view()) cdef unique_ptr[table] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -67,7 +69,7 @@ cpdef Table merge ( c_key_cols, c_column_order, c_null_precedence, - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/null_mask.pxd b/python/pylibcudf/pylibcudf/null_mask.pxd index 6eb10eddb2e..e7fa70e23ae 100644 --- a/python/pylibcudf/pylibcudf/null_mask.pxd +++ b/python/pylibcudf/pylibcudf/null_mask.pxd @@ -5,18 +5,19 @@ from pylibcudf.libcudf.types cimport mask_state, size_type from rmm.pylibrmm.device_buffer cimport DeviceBuffer from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream from .column cimport Column -cpdef DeviceBuffer copy_bitmask(Column col, Stream stream=*, DeviceMemoryResource mr=*) +cpdef DeviceBuffer copy_bitmask( + Column col, object stream = *, DeviceMemoryResource mr=* +) cpdef DeviceBuffer copy_bitmask_from_bitmask( object bitmask, size_type begin_bit, size_type end_bit, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) @@ -25,24 +26,24 @@ cpdef size_t bitmask_allocation_size_bytes(size_type number_of_bits) cpdef DeviceBuffer create_null_mask( size_type size, mask_state state=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) -cpdef tuple bitmask_and(list columns, Stream stream=*, DeviceMemoryResource mr=*) +cpdef tuple bitmask_and(list columns, object stream = *, DeviceMemoryResource mr=*) -cpdef tuple bitmask_or(list columns, Stream stream=*, DeviceMemoryResource mr=*) +cpdef tuple bitmask_or(list columns, object stream = *, DeviceMemoryResource mr=*) cpdef size_type null_count( object bitmask, size_type start, size_type stop, - Stream stream=* + object stream = * ) cpdef size_type index_of_first_set_bit( object bitmask, size_type start, size_type stop, - Stream stream=* + object stream = * ) diff --git a/python/pylibcudf/pylibcudf/null_mask.pyi b/python/pylibcudf/pylibcudf/null_mask.pyi index 98f6e60fb0d..45e130b704e 100644 --- a/python/pylibcudf/pylibcudf/null_mask.pyi +++ b/python/pylibcudf/pylibcudf/null_mask.pyi @@ -3,44 +3,44 @@ from rmm.pylibrmm.device_buffer import DeviceBuffer from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.span import Span from pylibcudf.types import MaskState +from pylibcudf.utils import CudaStreamLike def copy_bitmask( col: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> DeviceBuffer: ... def copy_bitmask_from_bitmask( bitmask: Span, begin_bit: int, end_bit: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> DeviceBuffer: ... def bitmask_allocation_size_bytes(number_of_bits: int) -> int: ... def create_null_mask( size: int, state: MaskState = MaskState.UNINITIALIZED, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> DeviceBuffer: ... def bitmask_and( columns: list[Column], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[DeviceBuffer, int]: ... def bitmask_or( columns: list[Column], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[DeviceBuffer, int]: ... def null_count( - bitmask: Span, start: int, stop: int, stream: Stream | None = None + bitmask: Span, start: int, stop: int, stream: CudaStreamLike | None = None ) -> int: ... def index_of_first_set_bit( - bitmask: Span, start: int, stop: int, stream: Stream | None = None + bitmask: Span, start: int, stop: int, stream: CudaStreamLike | None = None ) -> int: ... diff --git a/python/pylibcudf/pylibcudf/null_mask.pyx b/python/pylibcudf/pylibcudf/null_mask.pyx index 176e73047e2..164c51aca9f 100644 --- a/python/pylibcudf/pylibcudf/null_mask.pyx +++ b/python/pylibcudf/pylibcudf/null_mask.pyx @@ -19,6 +19,7 @@ from .span import is_span as py_is_span from .column cimport Column from .table cimport Table from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "bitmask_allocation_size_bytes", @@ -31,7 +32,7 @@ __all__ = [ ] cdef DeviceBuffer buffer_to_python( - device_buffer buf, Stream stream, DeviceMemoryResource mr + device_buffer buf, object stream, DeviceMemoryResource mr ): return DeviceBuffer.c_from_unique_ptr( make_unique[device_buffer](move(buf)), stream, mr @@ -40,7 +41,7 @@ cdef DeviceBuffer buffer_to_python( cpdef DeviceBuffer copy_bitmask( Column col, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Copies ``col``'s bitmask into a ``DeviceBuffer``. @@ -63,20 +64,21 @@ cpdef DeviceBuffer copy_bitmask( ``DeviceBuffer`` if ``col`` is not nullable """ cdef device_buffer db - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - db = cpp_null_mask.copy_bitmask(col.view(), stream.view(), mr.get_mr()) + db = cpp_null_mask.copy_bitmask(col.view(), _cs, mr.get_mr()) - return buffer_to_python(move(db), stream, mr) + return buffer_to_python(move(db), _stream, mr) cpdef DeviceBuffer copy_bitmask_from_bitmask( object bitmask, size_type begin_bit, size_type end_bit, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Copies a portion of a bitmask into a ``DeviceBuffer``. @@ -108,7 +110,8 @@ cpdef DeviceBuffer copy_bitmask_from_bitmask( f"got {type(bitmask).__name__}" ) cdef device_buffer db - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) cdef uintptr_t ptr = bitmask.ptr @@ -117,11 +120,11 @@ cpdef DeviceBuffer copy_bitmask_from_bitmask( ptr, begin_bit, end_bit, - stream.view(), + _cs, mr.get_mr() ) - return buffer_to_python(move(db), stream, mr) + return buffer_to_python(move(db), _stream, mr) cpdef size_t bitmask_allocation_size_bytes(size_type number_of_bits): @@ -148,7 +151,7 @@ cpdef size_t bitmask_allocation_size_bytes(size_type number_of_bits): cpdef DeviceBuffer create_null_mask( size_type size, mask_state state = mask_state.UNINITIALIZED, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Creates a ``DeviceBuffer`` for use as a null value indicator bitmask of a @@ -176,16 +179,17 @@ cpdef DeviceBuffer create_null_mask( state """ cdef device_buffer db - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - db = cpp_null_mask.create_null_mask(size, state, stream.view(), mr.get_mr()) + db = cpp_null_mask.create_null_mask(size, state, _cs, mr.get_mr()) - return buffer_to_python(move(db), stream, mr) + return buffer_to_python(move(db), _stream, mr) -cpdef tuple bitmask_and(list columns, Stream stream=None, DeviceMemoryResource mr=None): +cpdef tuple bitmask_and(list columns, object stream=None, DeviceMemoryResource mr=None): """Performs bitwise AND of the bitmasks of a list of columns. For details, see :cpp:func:`bitmask_and`. @@ -206,16 +210,19 @@ cpdef tuple bitmask_and(list columns, Stream stream=None, DeviceMemoryResource m """ cdef Table c_table = Table(columns) cdef pair[device_buffer, size_type] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_null_mask.bitmask_and(c_table.view(), stream.view(), mr.get_mr()) + c_result = cpp_null_mask.bitmask_and( + c_table.view(), _cs, mr.get_mr() + ) - return buffer_to_python(move(c_result.first), stream, mr), c_result.second + return buffer_to_python(move(c_result.first), _stream, mr), c_result.second -cpdef tuple bitmask_or(list columns, Stream stream=None, DeviceMemoryResource mr=None): +cpdef tuple bitmask_or(list columns, object stream=None, DeviceMemoryResource mr=None): """Performs bitwise OR of the bitmasks of a list of columns. For details, see :cpp:func:`bitmask_or`. @@ -236,20 +243,21 @@ cpdef tuple bitmask_or(list columns, Stream stream=None, DeviceMemoryResource mr """ cdef Table c_table = Table(columns) cdef pair[device_buffer, size_type] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_null_mask.bitmask_or(c_table.view(), stream.view(), mr.get_mr()) + c_result = cpp_null_mask.bitmask_or(c_table.view(), _cs, mr.get_mr()) - return buffer_to_python(move(c_result.first), stream, mr), c_result.second + return buffer_to_python(move(c_result.first), _stream, mr), c_result.second cpdef size_type null_count( object bitmask, size_type start, size_type stop, - Stream stream=None + object stream=None ): """Given a validity bitmask, counts the number of null elements. @@ -277,20 +285,21 @@ cpdef size_type null_count( f"got {type(bitmask).__name__}" ) cdef uintptr_t ptr = bitmask.ptr - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() with nogil: return cpp_null_mask.null_count( ptr, start, stop, - stream.view() + _cs ) cpdef size_type index_of_first_set_bit( object bitmask, size_type start, size_type stop, - Stream stream=None + object stream=None ): """Given a validity bitmask, returns the index of the first valid element relative to ``start``. @@ -319,11 +328,12 @@ cpdef size_type index_of_first_set_bit( f"got {type(bitmask).__name__}" ) cdef uintptr_t ptr = bitmask.ptr - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() with nogil: return cpp_null_mask.index_of_first_set_bit( ptr, start, stop, - stream.view() + _cs ) diff --git a/python/pylibcudf/pylibcudf/nvtext/byte_pair_encode.pxd b/python/pylibcudf/pylibcudf/nvtext/byte_pair_encode.pxd index 8cd73fe41ad..2bc3f75b174 100644 --- a/python/pylibcudf/pylibcudf/nvtext/byte_pair_encode.pxd +++ b/python/pylibcudf/pylibcudf/nvtext/byte_pair_encode.pxd @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -6,7 +6,6 @@ from pylibcudf.column cimport Column from pylibcudf.libcudf.nvtext.byte_pair_encode cimport bpe_merge_pairs from pylibcudf.scalar cimport Scalar from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cdef class BPEMergePairs: @@ -16,6 +15,6 @@ cpdef Column byte_pair_encoding( Column input, BPEMergePairs merge_pairs, Scalar separator=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/nvtext/byte_pair_encode.pyi b/python/pylibcudf/pylibcudf/nvtext/byte_pair_encode.pyi index 4abf1f52b4d..7ee48f72209 100644 --- a/python/pylibcudf/pylibcudf/nvtext/byte_pair_encode.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/byte_pair_encode.pyi @@ -1,17 +1,17 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar +from pylibcudf.utils import CudaStreamLike class BPEMergePairs: def __init__( self, merge_pairs: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ): ... @@ -19,6 +19,6 @@ def byte_pair_encoding( input: Column, merge_pairs: BPEMergePairs, separator: Scalar | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/nvtext/byte_pair_encode.pyx b/python/pylibcudf/pylibcudf/nvtext/byte_pair_encode.pyx index 001b9dfca1e..023e00a1169 100644 --- a/python/pylibcudf/pylibcudf/nvtext/byte_pair_encode.pyx +++ b/python/pylibcudf/pylibcudf/nvtext/byte_pair_encode.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from cython.operator cimport dereference @@ -19,6 +19,7 @@ from pylibcudf.scalar cimport Scalar from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["BPEMergePairs", "byte_pair_encoding"] @@ -30,14 +31,17 @@ cdef class BPEMergePairs: def __cinit__( self, Column merge_pairs, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): cdef column_view c_pairs = merge_pairs.view() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - self.c_obj = move(cpp_load_merge_pairs(c_pairs, stream.view(), mr.get_mr())) + self.c_obj = move( + cpp_load_merge_pairs(c_pairs, _cs, mr.get_mr()) + ) __hash__ = None @@ -45,7 +49,7 @@ cpdef Column byte_pair_encoding( Column input, BPEMergePairs merge_pairs, Scalar separator=None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -70,12 +74,13 @@ cpdef Column byte_pair_encoding( An encoded column of strings. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if separator is None: separator = Scalar.from_libcudf( - cpp_make_string_scalar(" ".encode(), stream.view(), mr.get_mr()) + cpp_make_string_scalar(" ".encode(), _stream.view().value(), mr.get_mr()) ) with nogil: @@ -84,9 +89,9 @@ cpdef Column byte_pair_encoding( input.view(), dereference(merge_pairs.c_obj.get()), dereference(separator.c_obj.get()), - stream.view(), + _cs, mr.get_mr() ) ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/nvtext/deduplicate.pxd b/python/pylibcudf/pylibcudf/nvtext/deduplicate.pxd index ecca0a495a1..d038d4a3e27 100644 --- a/python/pylibcudf/pylibcudf/nvtext/deduplicate.pxd +++ b/python/pylibcudf/pylibcudf/nvtext/deduplicate.pxd @@ -1,22 +1,21 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.libcudf.types cimport size_type from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column build_suffix_array( Column input, size_type min_width, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) cpdef Column resolve_duplicates( Column input, Column indices, size_type min_width, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) cpdef Column resolve_duplicates_pair( @@ -25,6 +24,6 @@ cpdef Column resolve_duplicates_pair( Column input2, Column indices2, size_type min_width, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/nvtext/deduplicate.pyi b/python/pylibcudf/pylibcudf/nvtext/deduplicate.pyi index 6e3d6883df4..653ee588f61 100644 --- a/python/pylibcudf/pylibcudf/nvtext/deduplicate.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/deduplicate.pyi @@ -1,22 +1,22 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column +from pylibcudf.utils import CudaStreamLike def build_suffix_array( input: Column, min_width: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def resolve_duplicates( input: Column, indices: Column, min_width: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def resolve_duplicates_pair( @@ -25,6 +25,6 @@ def resolve_duplicates_pair( input2: Column, indices2: Column, min_width: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/nvtext/deduplicate.pyx b/python/pylibcudf/pylibcudf/nvtext/deduplicate.pyx index c71ae479674..e679841a792 100644 --- a/python/pylibcudf/pylibcudf/nvtext/deduplicate.pyx +++ b/python/pylibcudf/pylibcudf/nvtext/deduplicate.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from cython.operator import dereference @@ -18,6 +18,7 @@ from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.librmm.device_buffer cimport device_buffer from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "build_suffix_array", @@ -36,14 +37,12 @@ cdef Column _column_from_suffix_array( device_buffer(), 0 ) - ), - stream, - mr + ), stream, mr ) cpdef Column build_suffix_array( - Column input, size_type min_width, Stream stream=None, DeviceMemoryResource mr=None + Column input, size_type min_width, object stream=None, DeviceMemoryResource mr=None ): """ Builds a suffix array for the input strings column. @@ -68,22 +67,23 @@ cpdef Column build_suffix_array( New column of suffix array """ cdef cpp_suffix_array_type c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_build_suffix_array( - input.view(), min_width, stream.view(), mr.get_mr() + input.view(), min_width, _cs, mr.get_mr() ) - return _column_from_suffix_array(move(c_result), stream, mr) + return _column_from_suffix_array(move(c_result), _stream, mr) cpdef Column resolve_duplicates( Column input, Column indices, size_type min_width, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -111,15 +111,16 @@ cpdef Column resolve_duplicates( New column of duplicate strings """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_resolve_duplicates( - input.view(), indices.view(), min_width, stream.view(), mr.get_mr() + input.view(), indices.view(), min_width, _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column resolve_duplicates_pair( @@ -128,7 +129,7 @@ cpdef Column resolve_duplicates_pair( Column input2, Column indices2, size_type min_width, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -161,7 +162,8 @@ cpdef Column resolve_duplicates_pair( """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -171,8 +173,8 @@ cpdef Column resolve_duplicates_pair( input2.view(), indices2.view(), min_width, - stream.view(), + _cs, mr.get_mr(), ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/nvtext/edit_distance.pxd b/python/pylibcudf/pylibcudf/nvtext/edit_distance.pxd index aca87ac4882..c0297ebd887 100644 --- a/python/pylibcudf/pylibcudf/nvtext/edit_distance.pxd +++ b/python/pylibcudf/pylibcudf/nvtext/edit_distance.pxd @@ -1,20 +1,19 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column edit_distance( Column input, Column targets, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef Column edit_distance_matrix( Column input, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) diff --git a/python/pylibcudf/pylibcudf/nvtext/edit_distance.pyi b/python/pylibcudf/pylibcudf/nvtext/edit_distance.pyi index 8c0e97b9951..5a6bde4cb66 100644 --- a/python/pylibcudf/pylibcudf/nvtext/edit_distance.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/edit_distance.pyi @@ -1,19 +1,19 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column +from pylibcudf.utils import CudaStreamLike def edit_distance( input: Column, targets: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def edit_distance_matrix( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/nvtext/edit_distance.pyx b/python/pylibcudf/pylibcudf/nvtext/edit_distance.pyx index 14d3b4539dc..4b9d3f6bcc3 100644 --- a/python/pylibcudf/pylibcudf/nvtext/edit_distance.pyx +++ b/python/pylibcudf/pylibcudf/nvtext/edit_distance.pyx @@ -17,13 +17,14 @@ from rmm.pylibrmm.stream cimport Stream from ..column cimport Column from ..utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["edit_distance", "edit_distance_matrix"] cpdef Column edit_distance( Column input, Column targets, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -48,18 +49,19 @@ cpdef Column edit_distance( cdef column_view c_strings = input.view() cdef column_view c_targets = targets.view() cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_edit_distance(c_strings, c_targets, stream.view(), mr.get_mr()) + c_result = cpp_edit_distance(c_strings, c_targets, _cs, mr.get_mr()) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column edit_distance_matrix( Column input, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -88,10 +90,11 @@ cpdef Column edit_distance_matrix( ) cdef column_view c_strings = input.view() cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_edit_distance_matrix(c_strings, stream.view(), mr.get_mr()) + c_result = cpp_edit_distance_matrix(c_strings, _cs, mr.get_mr()) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/nvtext/generate_ngrams.pxd b/python/pylibcudf/pylibcudf/nvtext/generate_ngrams.pxd index 1eb55f1fcf6..85477223954 100644 --- a/python/pylibcudf/pylibcudf/nvtext/generate_ngrams.pxd +++ b/python/pylibcudf/pylibcudf/nvtext/generate_ngrams.pxd @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libc.stdint cimport uint32_t @@ -6,21 +6,20 @@ from pylibcudf.column cimport Column from pylibcudf.libcudf.types cimport size_type from pylibcudf.scalar cimport Scalar from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column generate_ngrams( Column input, size_type ngrams, Scalar separator, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef Column generate_character_ngrams( Column input, size_type ngrams=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -28,6 +27,6 @@ cpdef Column hash_character_ngrams( Column input, size_type ngrams, uint32_t seed, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) diff --git a/python/pylibcudf/pylibcudf/nvtext/generate_ngrams.pyi b/python/pylibcudf/pylibcudf/nvtext/generate_ngrams.pyi index 7a522acc5a9..317fdb9ee73 100644 --- a/python/pylibcudf/pylibcudf/nvtext/generate_ngrams.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/generate_ngrams.pyi @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from typing import Any @@ -6,28 +6,28 @@ from typing import Any import numpy as np from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar +from pylibcudf.utils import CudaStreamLike def generate_ngrams( input: Column, ngrams: int, separator: Scalar, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def generate_character_ngrams( input: Column, ngrams: int = 2, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def hash_character_ngrams( input: Column, ngrams: int, seed: int | np.unsignedinteger[Any], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/nvtext/generate_ngrams.pyx b/python/pylibcudf/pylibcudf/nvtext/generate_ngrams.pyx index ca8a21c279c..6d70751a5a0 100644 --- a/python/pylibcudf/pylibcudf/nvtext/generate_ngrams.pyx +++ b/python/pylibcudf/pylibcudf/nvtext/generate_ngrams.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libc.stdint cimport uint32_t @@ -18,6 +18,7 @@ from pylibcudf.scalar cimport Scalar from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "generate_ngrams", @@ -29,7 +30,7 @@ cpdef Column generate_ngrams( Column input, size_type ngrams, Scalar separator, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -56,7 +57,8 @@ cpdef Column generate_ngrams( cdef column_view c_strings = input.view() cdef const string_scalar* c_separator = separator.c_obj.get() cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -64,16 +66,16 @@ cpdef Column generate_ngrams( c_strings, ngrams, c_separator[0], - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column generate_character_ngrams( Column input, size_type ngrams = 2, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -97,24 +99,25 @@ cpdef Column generate_character_ngrams( """ cdef column_view c_strings = input.view() cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_generate_character_ngrams( c_strings, ngrams, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column hash_character_ngrams( Column input, size_type ngrams, uint32_t seed, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -140,7 +143,8 @@ cpdef Column hash_character_ngrams( """ cdef column_view c_strings = input.view() cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -148,7 +152,7 @@ cpdef Column hash_character_ngrams( c_strings, ngrams, seed, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/nvtext/jaccard.pxd b/python/pylibcudf/pylibcudf/nvtext/jaccard.pxd index fbf8e99ac55..1e3a26454a1 100644 --- a/python/pylibcudf/pylibcudf/nvtext/jaccard.pxd +++ b/python/pylibcudf/pylibcudf/nvtext/jaccard.pxd @@ -1,16 +1,15 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.libcudf.types cimport size_type from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column jaccard_index( Column input1, Column input2, size_type width, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) diff --git a/python/pylibcudf/pylibcudf/nvtext/jaccard.pyi b/python/pylibcudf/pylibcudf/nvtext/jaccard.pyi index abc86597c0e..355d2d7a92f 100644 --- a/python/pylibcudf/pylibcudf/nvtext/jaccard.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/jaccard.pyi @@ -1,15 +1,15 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column +from pylibcudf.utils import CudaStreamLike def jaccard_index( input1: Column, input2: Column, width: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/nvtext/jaccard.pyx b/python/pylibcudf/pylibcudf/nvtext/jaccard.pyx index 4089853ca77..24a343e4508 100644 --- a/python/pylibcudf/pylibcudf/nvtext/jaccard.pyx +++ b/python/pylibcudf/pylibcudf/nvtext/jaccard.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -13,6 +13,7 @@ from pylibcudf.libcudf.types cimport size_type from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["jaccard_index"] @@ -20,7 +21,7 @@ cpdef Column jaccard_index( Column input1, Column input2, size_type width, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -49,7 +50,8 @@ cpdef Column jaccard_index( cdef column_view c_input1 = input1.view() cdef column_view c_input2 = input2.view() cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -57,8 +59,8 @@ cpdef Column jaccard_index( c_input1, c_input2, width, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/nvtext/minhash.pxd b/python/pylibcudf/pylibcudf/nvtext/minhash.pxd index 0647337324d..f26b1e30245 100644 --- a/python/pylibcudf/pylibcudf/nvtext/minhash.pxd +++ b/python/pylibcudf/pylibcudf/nvtext/minhash.pxd @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libc.stdint cimport uint32_t, uint64_t @@ -6,7 +6,6 @@ from pylibcudf.column cimport Column from pylibcudf.libcudf.types cimport size_type from pylibcudf.scalar cimport Scalar from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream ctypedef fused ColumnOrScalar: Column @@ -18,7 +17,7 @@ cpdef Column minhash( Column a, Column b, size_type width, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) @@ -28,7 +27,7 @@ cpdef Column minhash64( Column a, Column b, size_type width, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) @@ -38,7 +37,7 @@ cpdef Column minhash_ngrams( uint32_t seed, Column a, Column b, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) @@ -48,6 +47,6 @@ cpdef Column minhash64_ngrams( uint64_t seed, Column a, Column b, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/nvtext/minhash.pyi b/python/pylibcudf/pylibcudf/nvtext/minhash.pyi index ee924f8d7aa..5bce73dc991 100644 --- a/python/pylibcudf/pylibcudf/nvtext/minhash.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/minhash.pyi @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from typing import Any @@ -6,9 +6,9 @@ from typing import Any import numpy as np from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column +from pylibcudf.utils import CudaStreamLike def minhash( input: Column, @@ -16,7 +16,7 @@ def minhash( a: Column, b: Column, width: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def minhash64( @@ -25,7 +25,7 @@ def minhash64( a: Column, b: Column, width: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def minhash_ngrams( @@ -34,7 +34,7 @@ def minhash_ngrams( seed: int | np.unsignedinteger[Any], a: Column, b: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def minhash64_ngrams( @@ -43,6 +43,6 @@ def minhash64_ngrams( seed: int | np.unsignedinteger[Any], a: Column, b: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/nvtext/minhash.pyx b/python/pylibcudf/pylibcudf/nvtext/minhash.pyx index 1329d88060c..3029ed54c50 100644 --- a/python/pylibcudf/pylibcudf/nvtext/minhash.pyx +++ b/python/pylibcudf/pylibcudf/nvtext/minhash.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libc.stdint cimport uint32_t, uint64_t @@ -16,6 +16,7 @@ from pylibcudf.libcudf.types cimport size_type from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "minhash", @@ -30,7 +31,7 @@ cpdef Column minhash( Column a, Column b, size_type width, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """ @@ -58,7 +59,8 @@ cpdef Column minhash( List column of minhash values for each string per seed """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -68,11 +70,11 @@ cpdef Column minhash( a.view(), b.view(), width, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column minhash64( Column input, @@ -80,7 +82,7 @@ cpdef Column minhash64( Column a, Column b, size_type width, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """ @@ -110,7 +112,8 @@ cpdef Column minhash64( List column of minhash values for each string per seed """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -120,11 +123,11 @@ cpdef Column minhash64( a.view(), b.view(), width, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column minhash_ngrams( Column input, @@ -132,7 +135,7 @@ cpdef Column minhash_ngrams( uint32_t seed, Column a, Column b, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """ @@ -163,7 +166,8 @@ cpdef Column minhash_ngrams( value in columns a and b. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -173,11 +177,11 @@ cpdef Column minhash_ngrams( seed, a.view(), b.view(), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column minhash64_ngrams( Column input, @@ -185,7 +189,7 @@ cpdef Column minhash64_ngrams( uint64_t seed, Column a, Column b, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """ @@ -216,7 +220,8 @@ cpdef Column minhash64_ngrams( value in columns a and b. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -226,8 +231,8 @@ cpdef Column minhash64_ngrams( seed, a.view(), b.view(), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/nvtext/ngrams_tokenize.pxd b/python/pylibcudf/pylibcudf/nvtext/ngrams_tokenize.pxd index f410d778cb1..5deaa45c73f 100644 --- a/python/pylibcudf/pylibcudf/nvtext/ngrams_tokenize.pxd +++ b/python/pylibcudf/pylibcudf/nvtext/ngrams_tokenize.pxd @@ -1,11 +1,10 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.libcudf.types cimport size_type from pylibcudf.scalar cimport Scalar from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column ngrams_tokenize( @@ -13,6 +12,6 @@ cpdef Column ngrams_tokenize( size_type ngrams, Scalar delimiter, Scalar separator, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/nvtext/ngrams_tokenize.pyi b/python/pylibcudf/pylibcudf/nvtext/ngrams_tokenize.pyi index 1347b7e7087..99c309a21ff 100644 --- a/python/pylibcudf/pylibcudf/nvtext/ngrams_tokenize.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/ngrams_tokenize.pyi @@ -1,17 +1,17 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar +from pylibcudf.utils import CudaStreamLike def ngrams_tokenize( input: Column, ngrams: int, delimiter: Scalar, separator: Scalar, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/nvtext/ngrams_tokenize.pyx b/python/pylibcudf/pylibcudf/nvtext/ngrams_tokenize.pyx index f9f36244a1d..959c47d595d 100644 --- a/python/pylibcudf/pylibcudf/nvtext/ngrams_tokenize.pyx +++ b/python/pylibcudf/pylibcudf/nvtext/ngrams_tokenize.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from cython.operator cimport dereference @@ -15,6 +15,7 @@ from pylibcudf.scalar cimport Scalar from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["ngrams_tokenize"] @@ -23,7 +24,7 @@ cpdef Column ngrams_tokenize( size_type ngrams, Scalar delimiter, Scalar separator, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -52,7 +53,8 @@ cpdef Column ngrams_tokenize( New strings columns of tokens """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -61,7 +63,7 @@ cpdef Column ngrams_tokenize( ngrams, dereference(delimiter.get()), dereference(separator.get()), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/nvtext/normalize.pxd b/python/pylibcudf/pylibcudf/nvtext/normalize.pxd index 8c8623e07a3..30e459f75a5 100644 --- a/python/pylibcudf/pylibcudf/nvtext/normalize.pxd +++ b/python/pylibcudf/pylibcudf/nvtext/normalize.pxd @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp cimport bool @@ -6,16 +6,17 @@ from libcpp.memory cimport unique_ptr from pylibcudf.column cimport Column from pylibcudf.libcudf.nvtext.normalize cimport character_normalizer from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cdef class CharacterNormalizer: cdef unique_ptr[character_normalizer] c_obj -cpdef Column normalize_spaces(Column input, Stream stream=*, DeviceMemoryResource mr=*) +cpdef Column normalize_spaces( + Column input, object stream = *, DeviceMemoryResource mr=* +) cpdef Column normalize_characters( Column input, CharacterNormalizer normalizer, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/nvtext/normalize.pyi b/python/pylibcudf/pylibcudf/nvtext/normalize.pyi index 958adb10ada..0fbd2e7e725 100644 --- a/python/pylibcudf/pylibcudf/nvtext/normalize.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/normalize.pyi @@ -1,28 +1,28 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column +from pylibcudf.utils import CudaStreamLike class CharacterNormalizer: def __init__( self, do_lower_case: bool, special_tokens: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ): ... def normalize_spaces( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def normalize_characters( input: Column, normalizer: CharacterNormalizer, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/nvtext/normalize.pyx b/python/pylibcudf/pylibcudf/nvtext/normalize.pyx index 5f62189f2f5..8e29aad9121 100644 --- a/python/pylibcudf/pylibcudf/nvtext/normalize.pyx +++ b/python/pylibcudf/pylibcudf/nvtext/normalize.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from cython.operator cimport dereference @@ -12,6 +12,7 @@ from pylibcudf.libcudf.nvtext cimport normalize as cpp_normalize from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "CharacterNormalizer" @@ -28,18 +29,19 @@ cdef class CharacterNormalizer: self, bool do_lower_case, Column tokens, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): cdef column_view c_tokens = tokens.view() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: self.c_obj = move( cpp_normalize.create_character_normalizer( do_lower_case, c_tokens, - stream.view(), + _cs, mr.get_mr() ) ) @@ -47,7 +49,7 @@ cdef class CharacterNormalizer: __hash__ = None cpdef Column normalize_spaces( - Column input, Stream stream=None, DeviceMemoryResource mr=None + Column input, object stream=None, DeviceMemoryResource mr=None ): """ Returns a new strings column by normalizing the whitespace in @@ -68,21 +70,22 @@ cpdef Column normalize_spaces( New strings columns of normalized strings. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_normalize.normalize_spaces( - input.view(), stream.view(), mr.get_mr() + input.view(), _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column normalize_characters( Column input, CharacterNormalizer normalizer, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -105,15 +108,16 @@ cpdef Column normalize_characters( Normalized strings column """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_normalize.normalize_characters( input.view(), dereference(normalizer.c_obj.get()), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/nvtext/replace.pxd b/python/pylibcudf/pylibcudf/nvtext/replace.pxd index c6a9ed5ba67..1265f75a514 100644 --- a/python/pylibcudf/pylibcudf/nvtext/replace.pxd +++ b/python/pylibcudf/pylibcudf/nvtext/replace.pxd @@ -1,11 +1,10 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.libcudf.types cimport size_type from pylibcudf.scalar cimport Scalar from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column replace_tokens( @@ -13,7 +12,7 @@ cpdef Column replace_tokens( Column targets, Column replacements, Scalar delimiter=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -22,6 +21,6 @@ cpdef Column filter_tokens( size_type min_token_length, Scalar replacement=*, Scalar delimiter=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) diff --git a/python/pylibcudf/pylibcudf/nvtext/replace.pyi b/python/pylibcudf/pylibcudf/nvtext/replace.pyi index 09187c1edf1..a5e451cdb16 100644 --- a/python/pylibcudf/pylibcudf/nvtext/replace.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/replace.pyi @@ -1,18 +1,18 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar +from pylibcudf.utils import CudaStreamLike def replace_tokens( input: Column, targets: Column, replacements: Column, delimiter: Scalar | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def filter_tokens( @@ -20,6 +20,6 @@ def filter_tokens( min_token_length: int, replacement: Scalar | None = None, delimiter: Scalar | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/nvtext/replace.pyx b/python/pylibcudf/pylibcudf/nvtext/replace.pyx index db375e6993f..4b00d76bd64 100644 --- a/python/pylibcudf/pylibcudf/nvtext/replace.pyx +++ b/python/pylibcudf/pylibcudf/nvtext/replace.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from cython.operator cimport dereference @@ -19,6 +19,7 @@ from pylibcudf.scalar cimport Scalar from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["filter_tokens", "replace_tokens"] @@ -27,7 +28,7 @@ cpdef Column replace_tokens( Column targets, Column replacements, Scalar delimiter=None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -55,11 +56,12 @@ cpdef Column replace_tokens( New strings column with replaced strings """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if delimiter is None: delimiter = Scalar.from_libcudf( - cpp_make_string_scalar("".encode(), stream.view(), mr.get_mr()) + cpp_make_string_scalar("".encode(), _stream.view().value(), mr.get_mr()) ) with nogil: c_result = cpp_replace_tokens( @@ -67,10 +69,10 @@ cpdef Column replace_tokens( targets.view(), replacements.view(), dereference(delimiter.get()), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column filter_tokens( @@ -78,7 +80,7 @@ cpdef Column filter_tokens( size_type min_token_length, Scalar replacement=None, Scalar delimiter=None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -107,15 +109,16 @@ cpdef Column filter_tokens( New strings column of filtered strings """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if delimiter is None: delimiter = Scalar.from_libcudf( - cpp_make_string_scalar("".encode(), stream.view(), mr.get_mr()) + cpp_make_string_scalar("".encode(), _stream.view().value(), mr.get_mr()) ) if replacement is None: replacement = Scalar.from_libcudf( - cpp_make_string_scalar("".encode(), stream.view(), mr.get_mr()) + cpp_make_string_scalar("".encode(), _stream.view().value(), mr.get_mr()) ) with nogil: @@ -124,8 +127,8 @@ cpdef Column filter_tokens( min_token_length, dereference(replacement.get()), dereference(delimiter.get()), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/nvtext/stemmer.pxd b/python/pylibcudf/pylibcudf/nvtext/stemmer.pxd index 0b19c699ea8..d9f9ef1549c 100644 --- a/python/pylibcudf/pylibcudf/nvtext/stemmer.pxd +++ b/python/pylibcudf/pylibcudf/nvtext/stemmer.pxd @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp cimport bool @@ -6,7 +6,6 @@ from pylibcudf.column cimport Column from pylibcudf.libcudf.nvtext.stemmer cimport letter_type from pylibcudf.libcudf.types cimport size_type from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream ctypedef fused ColumnOrSize: Column @@ -16,10 +15,10 @@ cpdef Column is_letter( Column input, bool check_vowels, ColumnOrSize indices, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef Column porter_stemmer_measure( - Column input, Stream stream=*, DeviceMemoryResource mr=* + Column input, object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/nvtext/stemmer.pyi b/python/pylibcudf/pylibcudf/nvtext/stemmer.pyi index ae53ce887a4..5fef689a895 100644 --- a/python/pylibcudf/pylibcudf/nvtext/stemmer.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/stemmer.pyi @@ -1,20 +1,20 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column +from pylibcudf.utils import CudaStreamLike def is_letter( input: Column, check_vowels: bool, indices: Column | int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def porter_stemmer_measure( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/nvtext/stemmer.pyx b/python/pylibcudf/pylibcudf/nvtext/stemmer.pyx index 44dc6be5c60..e038cd03fb2 100644 --- a/python/pylibcudf/pylibcudf/nvtext/stemmer.pyx +++ b/python/pylibcudf/pylibcudf/nvtext/stemmer.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp cimport bool @@ -18,6 +18,7 @@ from pylibcudf.utils cimport _get_stream, _get_memory_resource from pylibcudf.libcudf.nvtext.stemmer import letter_type as LetterType # no-cython-lint from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["is_letter", "porter_stemmer_measure", "LetterType"] @@ -25,7 +26,7 @@ cpdef Column is_letter( Column input, bool check_vowels, ColumnOrSize indices, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -55,7 +56,8 @@ cpdef Column is_letter( New boolean column. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -63,14 +65,14 @@ cpdef Column is_letter( input.view(), letter_type.VOWEL if check_vowels else letter_type.CONSONANT, indices if ColumnOrSize is size_type else indices.view(), - stream.view() + _cs ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column porter_stemmer_measure( - Column input, Stream stream=None, DeviceMemoryResource mr=None + Column input, object stream=None, DeviceMemoryResource mr=None ): """ Returns the Porter Stemmer measurements of a strings column. @@ -92,12 +94,13 @@ cpdef Column porter_stemmer_measure( New column of measure values """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_porter_stemmer_measure(input.view(), stream.view(), mr.get_mr()) + c_result = cpp_porter_stemmer_measure(input.view(), _cs, mr.get_mr()) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) LetterType.__str__ = LetterType.__repr__ diff --git a/python/pylibcudf/pylibcudf/nvtext/tokenize.pxd b/python/pylibcudf/pylibcudf/nvtext/tokenize.pxd index 2ad694d1eca..8346d420440 100644 --- a/python/pylibcudf/pylibcudf/nvtext/tokenize.pxd +++ b/python/pylibcudf/pylibcudf/nvtext/tokenize.pxd @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -7,36 +7,35 @@ from pylibcudf.libcudf.nvtext.tokenize cimport tokenize_vocabulary from pylibcudf.libcudf.types cimport size_type from pylibcudf.scalar cimport Scalar from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cdef class TokenizeVocabulary: cdef unique_ptr[tokenize_vocabulary] c_obj cpdef Column tokenize_scalar( - Column input, Scalar delimiter=*, Stream stream=*, DeviceMemoryResource mr=* + Column input, Scalar delimiter=*, object stream = *, DeviceMemoryResource mr=* ) cpdef Column tokenize_column( - Column input, Column delimiters, Stream stream=*, DeviceMemoryResource mr=* + Column input, Column delimiters, object stream = *, DeviceMemoryResource mr=* ) cpdef Column count_tokens_scalar( - Column input, Scalar delimiter=*, Stream stream=*, DeviceMemoryResource mr=* + Column input, Scalar delimiter=*, object stream = *, DeviceMemoryResource mr=* ) cpdef Column count_tokens_column( - Column input, Column delimiters, Stream stream=*, DeviceMemoryResource mr=* + Column input, Column delimiters, object stream = *, DeviceMemoryResource mr=* ) cpdef Column character_tokenize( - Column input, Stream stream=*, DeviceMemoryResource mr=* + Column input, object stream = *, DeviceMemoryResource mr=* ) cpdef Column detokenize( Column input, Column row_indices, Scalar separator=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -45,6 +44,6 @@ cpdef Column tokenize_with_vocabulary( TokenizeVocabulary vocabulary, Scalar delimiter, size_type default_id=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) diff --git a/python/pylibcudf/pylibcudf/nvtext/tokenize.pyi b/python/pylibcudf/pylibcudf/nvtext/tokenize.pyi index c6e2d4cfcb4..72a5209902e 100644 --- a/python/pylibcudf/pylibcudf/nvtext/tokenize.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/tokenize.pyi @@ -1,54 +1,54 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar +from pylibcudf.utils import CudaStreamLike class TokenizeVocabulary: def __init__( self, vocab: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ): ... def tokenize_scalar( input: Column, delimiter: Scalar | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def tokenize_column( input: Column, delimiters: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def count_tokens_scalar( input: Column, delimiter: Scalar | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def count_tokens_column( input: Column, delimiters: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def character_tokenize( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def detokenize( input: Column, row_indices: Column, separator: Scalar | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def tokenize_with_vocabulary( @@ -56,6 +56,6 @@ def tokenize_with_vocabulary( vocabulary: TokenizeVocabulary, delimiter: Scalar, default_id: int = -1, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/nvtext/tokenize.pyx b/python/pylibcudf/pylibcudf/nvtext/tokenize.pyx index e296ea38a58..4e44d781cc4 100644 --- a/python/pylibcudf/pylibcudf/nvtext/tokenize.pyx +++ b/python/pylibcudf/pylibcudf/nvtext/tokenize.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from cython.operator cimport dereference @@ -24,6 +24,7 @@ from pylibcudf.scalar cimport Scalar from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "TokenizeVocabulary", @@ -41,19 +42,20 @@ cdef class TokenizeVocabulary: For details, see :cpp:class:`cudf::nvtext::tokenize_vocabulary`. """ - def __cinit__(self, Column vocab, Stream stream=None, DeviceMemoryResource mr=None): + def __cinit__(self, Column vocab, object stream=None, DeviceMemoryResource mr=None): cdef column_view c_vocab = vocab.view() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - self.c_obj = move(cpp_load_vocabulary(c_vocab, stream.view(), mr.get_mr())) + self.c_obj = move(cpp_load_vocabulary(c_vocab, _cs, mr.get_mr())) __hash__ = None cpdef Column tokenize_scalar( Column input, Scalar delimiter=None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -77,26 +79,27 @@ cpdef Column tokenize_scalar( New strings columns of tokens """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if delimiter is None: delimiter = Scalar.from_libcudf( - cpp_make_string_scalar("".encode(), stream.view(), mr.get_mr()) + cpp_make_string_scalar("".encode(), _stream.view().value(), mr.get_mr()) ) with nogil: c_result = cpp_tokenize( input.view(), dereference(delimiter.c_obj.get()), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column tokenize_column( - Column input, Column delimiters, Stream stream=None, DeviceMemoryResource mr=None + Column input, Column delimiters, object stream=None, DeviceMemoryResource mr=None ): """ Returns a single column of strings by tokenizing the input @@ -119,23 +122,24 @@ cpdef Column tokenize_column( New strings columns of tokens """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_tokenize( input.view(), delimiters.view(), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column count_tokens_scalar( Column input, Scalar delimiter=None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -159,26 +163,27 @@ cpdef Column count_tokens_scalar( New column of token counts """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if delimiter is None: delimiter = Scalar.from_libcudf( - cpp_make_string_scalar("".encode(), stream.view(), mr.get_mr()) + cpp_make_string_scalar("".encode(), _stream.view().value(), mr.get_mr()) ) with nogil: c_result = cpp_count_tokens( input.view(), dereference(delimiter.c_obj.get()), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column count_tokens_column( - Column input, Column delimiters, Stream stream=None, DeviceMemoryResource mr=None + Column input, Column delimiters, object stream=None, DeviceMemoryResource mr=None ): """ Returns the number of tokens in each string of a strings column @@ -201,21 +206,22 @@ cpdef Column count_tokens_column( New column of token counts """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_count_tokens( input.view(), delimiters.view(), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column character_tokenize( - Column input, Stream stream=None, DeviceMemoryResource mr=None + Column input, object stream=None, DeviceMemoryResource mr=None ): """ Returns a single column of strings by converting @@ -236,18 +242,19 @@ cpdef Column character_tokenize( New strings columns of tokens """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_character_tokenize(input.view(), stream.view(), mr.get_mr()) + c_result = cpp_character_tokenize(input.view(), _cs, mr.get_mr()) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column detokenize( Column input, Column row_indices, Scalar separator=None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -273,12 +280,13 @@ cpdef Column detokenize( New strings columns of tokens """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if separator is None: separator = Scalar.from_libcudf( - cpp_make_string_scalar(" ".encode(), stream.view(), mr.get_mr()) + cpp_make_string_scalar(" ".encode(), _stream.view().value(), mr.get_mr()) ) with nogil: @@ -286,18 +294,18 @@ cpdef Column detokenize( input.view(), row_indices.view(), dereference(separator.c_obj.get()), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column tokenize_with_vocabulary( Column input, TokenizeVocabulary vocabulary, Scalar delimiter, size_type default_id=-1, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -325,7 +333,8 @@ cpdef Column tokenize_with_vocabulary( Lists column of token ids """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -334,8 +343,8 @@ cpdef Column tokenize_with_vocabulary( dereference(vocabulary.c_obj.get()), dereference(delimiter.c_obj.get()), default_id, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/nvtext/wordpiece_tokenize.pxd b/python/pylibcudf/pylibcudf/nvtext/wordpiece_tokenize.pxd index 3f7685903e0..604a566c701 100644 --- a/python/pylibcudf/pylibcudf/nvtext/wordpiece_tokenize.pxd +++ b/python/pylibcudf/pylibcudf/nvtext/wordpiece_tokenize.pxd @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -6,7 +6,6 @@ from pylibcudf.column cimport Column from pylibcudf.libcudf.nvtext.wordpiece_tokenize cimport wordpiece_vocabulary from pylibcudf.libcudf.types cimport size_type from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cdef class WordPieceVocabulary: cdef unique_ptr[wordpiece_vocabulary] c_obj @@ -15,6 +14,6 @@ cpdef Column wordpiece_tokenize( Column input, WordPieceVocabulary vocabulary, size_type max_words_per_row, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/nvtext/wordpiece_tokenize.pyi b/python/pylibcudf/pylibcudf/nvtext/wordpiece_tokenize.pyi index e91cfc8f21e..e77a8c86a69 100644 --- a/python/pylibcudf/pylibcudf/nvtext/wordpiece_tokenize.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/wordpiece_tokenize.pyi @@ -1,16 +1,16 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column +from pylibcudf.utils import CudaStreamLike class WordPieceVocabulary: def __init__( self, vocab: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ): ... @@ -18,6 +18,6 @@ def wordpiece_tokenize( input: Column, vocabulary: WordPieceVocabulary, max_words_per_row: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/nvtext/wordpiece_tokenize.pyx b/python/pylibcudf/pylibcudf/nvtext/wordpiece_tokenize.pyx index b6c516cf739..dfdb563087d 100644 --- a/python/pylibcudf/pylibcudf/nvtext/wordpiece_tokenize.pyx +++ b/python/pylibcudf/pylibcudf/nvtext/wordpiece_tokenize.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from cython.operator cimport dereference @@ -15,6 +15,7 @@ from pylibcudf.libcudf.types cimport size_type from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "WordPieceVocabulary", @@ -29,15 +30,16 @@ cdef class WordPieceVocabulary: def __cinit__( self, Column vocab, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): cdef column_view c_vocab = vocab.view() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: self.c_obj = move(cpp_load_wordpiece_vocabulary( - c_vocab, stream.view(), mr.get_mr() + c_vocab, _cs, mr.get_mr() )) __hash__ = None @@ -46,7 +48,7 @@ cpdef Column wordpiece_tokenize( Column input, WordPieceVocabulary vocabulary, size_type max_words_per_row, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -73,7 +75,8 @@ cpdef Column wordpiece_tokenize( Lists column of token ids """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -81,8 +84,8 @@ cpdef Column wordpiece_tokenize( input.view(), dereference(vocabulary.c_obj.get()), max_words_per_row, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/partitioning.pxd b/python/pylibcudf/pylibcudf/partitioning.pxd index 096b4eb99e8..84c9b647691 100644 --- a/python/pylibcudf/pylibcudf/partitioning.pxd +++ b/python/pylibcudf/pylibcudf/partitioning.pxd @@ -1,7 +1,6 @@ # SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from libc.stdint cimport uint32_t @@ -20,7 +19,7 @@ cpdef tuple[Table, list] hash_partition( int num_partitions, hash_id hash_function = *, uint32_t seed = *, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -28,7 +27,7 @@ cpdef tuple[Table, list] partition( Table t, Column partition_map, int num_partitions, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -36,6 +35,6 @@ cpdef tuple[Table, list] round_robin_partition( Table input, int num_partitions, int start_partition=*, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) diff --git a/python/pylibcudf/pylibcudf/partitioning.pyi b/python/pylibcudf/pylibcudf/partitioning.pyi index 081ee53731f..971346421ea 100644 --- a/python/pylibcudf/pylibcudf/partitioning.pyi +++ b/python/pylibcudf/pylibcudf/partitioning.pyi @@ -4,10 +4,10 @@ from enum import IntEnum from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.table import Table +from pylibcudf.utils import CudaStreamLike class HashId(IntEnum): HASH_IDENTITY = ... @@ -19,20 +19,20 @@ def hash_partition( num_partitions: int, hash_function: HashId = ..., seed: int = ..., - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[Table, list[int]]: ... def partition( t: Table, partition_map: Column, num_partitions: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[Table, list[int]]: ... def round_robin_partition( input: Table, num_partitions: int, start_partition: int = 0, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[Table, list[int]]: ... diff --git a/python/pylibcudf/pylibcudf/partitioning.pyx b/python/pylibcudf/pylibcudf/partitioning.pyx index b8da9249656..62e35ab9cca 100644 --- a/python/pylibcudf/pylibcudf/partitioning.pyx +++ b/python/pylibcudf/pylibcudf/partitioning.pyx @@ -15,6 +15,7 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from .column cimport Column from .table cimport Table from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ @@ -29,7 +30,7 @@ cpdef tuple[Table, list] hash_partition( int num_partitions, cpp_partitioning.hash_id hash_function = cpp_partitioning.hash_id.HASH_MURMUR3, uint32_t seed = cpp_partitioning.DEFAULT_HASH_SEED, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -63,7 +64,8 @@ cpdef tuple[Table, list] hash_partition( cdef pair[unique_ptr[table], vector[libcudf_types.size_type]] c_result cdef int c_num_partitions = num_partitions cdef vector[libcudf_types.size_type] columns_to_hash - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if TableOrList is Table: with nogil: @@ -73,7 +75,7 @@ cpdef tuple[Table, list] hash_partition( c_num_partitions, hash_function, seed, - stream.view(), + _cs, mr.get_mr() ) else: @@ -85,17 +87,17 @@ cpdef tuple[Table, list] hash_partition( c_num_partitions, hash_function, seed, - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result.first), stream, mr), list(c_result.second) + return Table.from_libcudf(move(c_result.first), _stream, mr), list(c_result.second) cpdef tuple[Table, list] partition( Table t, Column partition_map, int num_partitions, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -126,7 +128,8 @@ cpdef tuple[Table, list] partition( cdef pair[unique_ptr[table], vector[libcudf_types.size_type]] c_result cdef int c_num_partitions = num_partitions - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -134,18 +137,18 @@ cpdef tuple[Table, list] partition( t.view(), partition_map.view(), c_num_partitions, - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result.first), stream, mr), list(c_result.second) + return Table.from_libcudf(move(c_result.first), _stream, mr), list(c_result.second) cpdef tuple[Table, list] round_robin_partition( Table input, int num_partitions, int start_partition=0, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -176,7 +179,8 @@ cpdef tuple[Table, list] round_robin_partition( cdef int c_num_partitions = num_partitions cdef int c_start_partition = start_partition - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -184,8 +188,8 @@ cpdef tuple[Table, list] round_robin_partition( input.view(), c_num_partitions, c_start_partition, - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result.first), stream, mr), list(c_result.second) + return Table.from_libcudf(move(c_result.first), _stream, mr), list(c_result.second) diff --git a/python/pylibcudf/pylibcudf/quantiles.pxd b/python/pylibcudf/pylibcudf/quantiles.pxd index 9492ef8ce38..668e8015688 100644 --- a/python/pylibcudf/pylibcudf/quantiles.pxd +++ b/python/pylibcudf/pylibcudf/quantiles.pxd @@ -1,9 +1,8 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.vector cimport vector from pylibcudf.libcudf.types cimport interpolation, sorted from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream from .column cimport Column from .table cimport Table @@ -15,7 +14,7 @@ cpdef Column quantile( interpolation interp = *, Column ordered_indices = *, bint exact = *, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -26,6 +25,6 @@ cpdef Table quantiles( sorted is_input_sorted = *, list column_order = *, list null_precedence = *, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) diff --git a/python/pylibcudf/pylibcudf/quantiles.pyi b/python/pylibcudf/pylibcudf/quantiles.pyi index 2e414357651..9af646407ab 100644 --- a/python/pylibcudf/pylibcudf/quantiles.pyi +++ b/python/pylibcudf/pylibcudf/quantiles.pyi @@ -1,14 +1,14 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from collections.abc import Iterable from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.table import Table from pylibcudf.types import Interpolation, NullOrder, Order, Sorted +from pylibcudf.utils import CudaStreamLike def quantile( input: Column, @@ -16,7 +16,7 @@ def quantile( interp: Interpolation = Interpolation.LINEAR, ordered_indices: Column | None = None, exact: bool = True, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def quantiles( @@ -26,6 +26,6 @@ def quantiles( is_input_sorted: Sorted = Sorted.NO, column_order: list[Order] | None = None, null_precedence: list[NullOrder] | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... diff --git a/python/pylibcudf/pylibcudf/quantiles.pyx b/python/pylibcudf/pylibcudf/quantiles.pyx index de1ee3344d3..f02643754cb 100644 --- a/python/pylibcudf/pylibcudf/quantiles.pyx +++ b/python/pylibcudf/pylibcudf/quantiles.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp cimport bool @@ -20,6 +20,7 @@ from .column cimport Column from .table cimport Table from .types cimport interpolation from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["quantile", "quantiles"] @@ -29,7 +30,7 @@ cpdef Column quantile( interpolation interp = interpolation.LINEAR, Column ordered_indices = None, bool exact=True, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Computes quantiles with interpolation. @@ -74,7 +75,8 @@ cpdef Column quantile( else: ordered_indices_view = ordered_indices.view() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -84,11 +86,11 @@ cpdef Column quantile( interp, ordered_indices_view, exact, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Table quantiles( @@ -98,7 +100,7 @@ cpdef Table quantiles( sorted is_input_sorted = sorted.NO, list column_order = None, list null_precedence = None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Computes row quantiles with interpolation. @@ -156,7 +158,8 @@ cpdef Table quantiles( if null_precedence is not None: null_precedence_vec = null_precedence - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -167,8 +170,8 @@ cpdef Table quantiles( is_input_sorted, column_order_vec, null_precedence_vec, - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/reduce.pxd b/python/pylibcudf/pylibcudf/reduce.pxd index e9acd2aaed5..dc33d7053f4 100644 --- a/python/pylibcudf/pylibcudf/reduce.pxd +++ b/python/pylibcudf/pylibcudf/reduce.pxd @@ -4,7 +4,6 @@ from libcpp cimport bool from pylibcudf.libcudf.reduce cimport scan_type from pylibcudf.libcudf.types cimport nan_policy, null_policy, size_type -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from .aggregation cimport Aggregation @@ -18,7 +17,7 @@ cpdef Scalar reduce( Aggregation agg, DataType data_type, Scalar init = *, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -26,11 +25,11 @@ cpdef Column scan( Column col, Aggregation agg, scan_type inclusive, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) -cpdef tuple minmax(Column col, Stream stream = *, DeviceMemoryResource mr = *) +cpdef tuple minmax(Column col, object stream = *, DeviceMemoryResource mr = *) cpdef bool is_valid_reduce_aggregation(DataType source, Aggregation agg) @@ -38,12 +37,12 @@ cpdef size_type unique_count( Column source, null_policy null_handling, nan_policy nan_handling, - Stream stream = * + object stream = * ) cpdef size_type distinct_count( Column source, null_policy null_handling, nan_policy nan_handling, - Stream stream = * + object stream = * ) diff --git a/python/pylibcudf/pylibcudf/reduce.pyi b/python/pylibcudf/pylibcudf/reduce.pyi index 5956b93661c..9e1c643b0cd 100644 --- a/python/pylibcudf/pylibcudf/reduce.pyi +++ b/python/pylibcudf/pylibcudf/reduce.pyi @@ -4,12 +4,12 @@ from enum import IntEnum from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.aggregation import Aggregation from pylibcudf.column import Column from pylibcudf.scalar import Scalar from pylibcudf.types import DataType, NanPolicy, NullPolicy +from pylibcudf.utils import CudaStreamLike class ScanType(IntEnum): INCLUSIVE = ... @@ -19,19 +19,19 @@ def reduce( col: Column, agg: Aggregation, data_type: DataType, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Scalar: ... def scan( col: Column, agg: Aggregation, inclusive: ScanType, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def minmax( col: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[Scalar, Scalar]: ... def is_valid_reduce_aggregation( @@ -41,11 +41,11 @@ def unique_count( source: Column, null_handling: NullPolicy, nan_handling: NanPolicy, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, ) -> int: ... def distinct_count( source: Column, null_handling: NullPolicy, nan_handling: NanPolicy, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, ) -> int: ... diff --git a/python/pylibcudf/pylibcudf/reduce.pyx b/python/pylibcudf/pylibcudf/reduce.pyx index 54036b73e85..95c3555d021 100644 --- a/python/pylibcudf/pylibcudf/reduce.pyx +++ b/python/pylibcudf/pylibcudf/reduce.pyx @@ -31,6 +31,7 @@ from .types cimport DataType from .utils cimport _get_stream, _get_memory_resource from pylibcudf.libcudf.reduce import scan_type as ScanType # no-cython-lint +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "ScanType", @@ -47,7 +48,7 @@ cpdef Scalar reduce( Aggregation agg, DataType data_type, Scalar init=None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Perform a reduction on a column @@ -79,7 +80,8 @@ cpdef Scalar reduce( cdef optional[reference_wrapper[constscalar]] c_init cdef const scalar* c_init_ptr - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if init is not None: @@ -96,7 +98,7 @@ cpdef Scalar reduce( dereference(c_agg), data_type.c_obj, c_init, - stream.view(), + _cs, mr.get_mr() ) return Scalar.from_libcudf(move(result)) @@ -106,7 +108,7 @@ cpdef Column scan( Column col, Aggregation agg, scan_type inclusive, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Perform a scan on a column @@ -134,7 +136,8 @@ cpdef Column scan( cdef unique_ptr[column] result cdef const scan_aggregation *c_agg = agg.view_underlying_as_scan() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -143,13 +146,13 @@ cpdef Column scan( dereference(c_agg), inclusive, null_policy.EXCLUDE, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) -cpdef tuple minmax(Column col, Stream stream=None, DeviceMemoryResource mr=None): +cpdef tuple minmax(Column col, object stream=None, DeviceMemoryResource mr=None): """Compute the minimum and maximum of a column For details, see ``cudf::minmax`` documentation. @@ -173,11 +176,12 @@ cpdef tuple minmax(Column col, Stream stream=None, DeviceMemoryResource mr=None) cdef Scalar min_scalar cdef Scalar max_scalar - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - result = cpp_minmax(col.view(), stream.view(), mr.get_mr()) + result = cpp_minmax(col.view(), _cs, mr.get_mr()) min_scalar = Scalar.from_libcudf(move(result.first)) max_scalar = Scalar.from_libcudf(move(result.second)) @@ -206,7 +210,7 @@ cpdef size_type unique_count( Column source, null_policy null_handling, nan_policy nan_handling, - Stream stream=None + object stream=None ): """Returns the number of unique consecutive elements in the input column. @@ -231,10 +235,10 @@ cpdef size_type unique_count( If the input column is sorted, then unique_count can produce the same result as distinct_count, but faster. """ - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) return cpp_unique_count.unique_count( - source.view(), null_handling, nan_handling, stream.view() + source.view(), null_handling, nan_handling, _stream.view().value() ) @@ -242,7 +246,7 @@ cpdef size_type distinct_count( Column source, null_policy null_handling, nan_policy nan_handling, - Stream stream=None + object stream=None ): """Returns the number of distinct elements in the input column. @@ -262,10 +266,10 @@ cpdef size_type distinct_count( size_type The number of distinct elements in the input column. """ - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) return cpp_distinct_count.distinct_count( - source.view(), null_handling, nan_handling, stream.view() + source.view(), null_handling, nan_handling, _stream.view().value() ) diff --git a/python/pylibcudf/pylibcudf/replace.pxd b/python/pylibcudf/pylibcudf/replace.pxd index 49b57753eb1..7e78e92d514 100644 --- a/python/pylibcudf/pylibcudf/replace.pxd +++ b/python/pylibcudf/pylibcudf/replace.pxd @@ -1,9 +1,8 @@ -# SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp cimport bool from pylibcudf.libcudf.replace cimport replace_policy -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from .column cimport Column @@ -22,7 +21,7 @@ ctypedef fused ReplacementType: cpdef Column replace_nulls( Column source_column, ReplacementType replacement, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -30,7 +29,7 @@ cpdef Column find_and_replace_all( Column source_column, Column values_to_replace, Column replacement_values, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -40,13 +39,13 @@ cpdef Column clamp( Scalar hi, Scalar lo_replace=*, Scalar hi_replace=*, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) cpdef Column normalize_nans_and_zeros( Column source_column, bool inplace=*, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) diff --git a/python/pylibcudf/pylibcudf/replace.pyi b/python/pylibcudf/pylibcudf/replace.pyi index d7a35721769..f74e06c3909 100644 --- a/python/pylibcudf/pylibcudf/replace.pyi +++ b/python/pylibcudf/pylibcudf/replace.pyi @@ -1,13 +1,13 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from enum import IntEnum from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar +from pylibcudf.utils import CudaStreamLike class ReplacePolicy(IntEnum): PRECEDING = ... @@ -16,14 +16,14 @@ class ReplacePolicy(IntEnum): def replace_nulls( source_column: Column, replacement: Column | Scalar | ReplacePolicy, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def find_and_replace_all( source_column: Column, values_to_replace: Column, replacement_values: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def clamp( @@ -32,12 +32,12 @@ def clamp( hi: Scalar, lo_replace: Scalar | None = None, hi_replace: Scalar | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def normalize_nans_and_zeros( source_column: Column, inplace: bool = False, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/replace.pyx b/python/pylibcudf/pylibcudf/replace.pyx index c3730e3971f..4a5cc162551 100644 --- a/python/pylibcudf/pylibcudf/replace.pyx +++ b/python/pylibcudf/pylibcudf/replace.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 @@ -18,6 +18,7 @@ from pylibcudf.libcudf.replace import \ from .column cimport Column from .scalar cimport Scalar from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "ReplacePolicy", @@ -31,7 +32,7 @@ __all__ = [ cpdef Column replace_nulls( Column source_column, ReplacementType replacement, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Replace nulls in source_column. @@ -70,7 +71,8 @@ cpdef Column replace_nulls( cdef unique_ptr[column] c_result cdef replace_policy policy - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) # Due to https://github.com/cython/cython/issues/5984, if this function is @@ -84,10 +86,10 @@ cpdef Column replace_nulls( c_result = cpp_replace.replace_nulls( source_column.view(), policy, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) else: raise TypeError("replacement must be a Column, Scalar, or replace_policy") @@ -96,33 +98,33 @@ cpdef Column replace_nulls( c_result = cpp_replace.replace_nulls( source_column.view(), replacement.view(), - stream.view(), + _cs, mr.get_mr() ) elif ReplacementType is Scalar: c_result = cpp_replace.replace_nulls( source_column.view(), dereference(replacement.c_obj), - stream.view(), + _cs, mr.get_mr() ) elif ReplacementType is replace_policy: c_result = cpp_replace.replace_nulls( source_column.view(), replacement, - stream.view(), + _cs, mr.get_mr() ) else: assert False, "Internal error. Please contact pylibcudf developers" - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column find_and_replace_all( Column source_column, Column values_to_replace, Column replacement_values, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Replace all occurrences of values_to_replace with replacement_values. @@ -150,7 +152,8 @@ cpdef Column find_and_replace_all( """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -158,10 +161,10 @@ cpdef Column find_and_replace_all( source_column.view(), values_to_replace.view(), replacement_values.view(), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column clamp( @@ -170,7 +173,7 @@ cpdef Column clamp( Scalar hi, Scalar lo_replace=None, Scalar hi_replace=None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Clamp the values in source_column to the range [lo, hi]. @@ -206,7 +209,8 @@ cpdef Column clamp( cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -215,7 +219,7 @@ cpdef Column clamp( source_column.view(), dereference(lo.c_obj), dereference(hi.c_obj), - stream.view(), + _cs, mr.get_mr() ) else: @@ -225,16 +229,16 @@ cpdef Column clamp( dereference(lo_replace.c_obj), dereference(hi.c_obj), dereference(hi_replace.c_obj), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column normalize_nans_and_zeros( Column source_column, bool inplace=False, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Normalize NaNs and zeros in source_column. @@ -260,24 +264,25 @@ cpdef Column normalize_nans_and_zeros( """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: if inplace: cpp_replace.normalize_nans_and_zeros( source_column.mutable_view(), - stream.view(), + _cs, mr.get_mr() ) else: c_result = cpp_replace.normalize_nans_and_zeros( source_column.view(), - stream.view(), + _cs, mr.get_mr() ) if not inplace: - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) ReplacePolicy.__str__ = ReplacePolicy.__repr__ diff --git a/python/pylibcudf/pylibcudf/reshape.pxd b/python/pylibcudf/pylibcudf/reshape.pxd index fd2eb9f31ec..09a111770b5 100644 --- a/python/pylibcudf/pylibcudf/reshape.pxd +++ b/python/pylibcudf/pylibcudf/reshape.pxd @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libc.stddef cimport size_t @@ -6,7 +6,6 @@ from libc.stdint cimport uintptr_t from pylibcudf.libcudf.types cimport size_type -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.device_buffer cimport DeviceBuffer from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource @@ -17,17 +16,17 @@ from .types cimport DataType cpdef Column interleave_columns( - Table source_table, Stream stream=*, DeviceMemoryResource mr=* + Table source_table, object stream = *, DeviceMemoryResource mr=* ) cpdef Table tile( Table source_table, size_type count, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) cpdef void table_to_array( Table input_table, uintptr_t ptr, size_t size, - Stream stream=* + object stream = * ) diff --git a/python/pylibcudf/pylibcudf/reshape.pyi b/python/pylibcudf/pylibcudf/reshape.pyi index c8ca83be981..03acda18353 100644 --- a/python/pylibcudf/pylibcudf/reshape.pyi +++ b/python/pylibcudf/pylibcudf/reshape.pyi @@ -1,26 +1,26 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.table import Table +from pylibcudf.utils import CudaStreamLike def interleave_columns( source_table: Table, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def tile( source_table: Table, count: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def table_to_array( input_table: Table, ptr: int, size: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, ) -> None: ... diff --git a/python/pylibcudf/pylibcudf/reshape.pyx b/python/pylibcudf/pylibcudf/reshape.pyx index b001b289794..a81dadf62ce 100644 --- a/python/pylibcudf/pylibcudf/reshape.pyx +++ b/python/pylibcudf/pylibcudf/reshape.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libc.stddef cimport size_t @@ -24,11 +24,12 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from .column cimport Column from .table cimport Table from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["interleave_columns", "tile", "table_to_array"] cpdef Column interleave_columns( - Table source_table, Stream stream=None, DeviceMemoryResource mr=None + Table source_table, object stream=None, DeviceMemoryResource mr=None ): """Interleave columns of a table into a single column. @@ -55,21 +56,22 @@ cpdef Column interleave_columns( A new column which is the result of interleaving the input columns """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_interleave_columns( - source_table.view(), stream.view(), mr.get_mr() + source_table.view(), _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Table tile( Table source_table, size_type count, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Repeats the rows from input table count times to form a new table. @@ -93,22 +95,23 @@ cpdef Table tile( The table containing the tiled "rows" """ cdef unique_ptr[table] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_tile( - source_table.view(), count, stream.view(), mr.get_mr() + source_table.view(), count, _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef void table_to_array( Table input_table, uintptr_t ptr, size_t size, - Stream stream=None + object stream=None ): """ Copy a table into a preallocated column-major device array. @@ -129,7 +132,8 @@ cpdef void table_to_array( raise ValueError( "Size exceeds the size_t limit." ) - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() cdef device_span[byte] span = device_span[byte]( ptr, size @@ -139,5 +143,5 @@ cpdef void table_to_array( cpp_table_to_array( input_table.view(), span, - stream.view() + _cs ) diff --git a/python/pylibcudf/pylibcudf/rolling.pxd b/python/pylibcudf/pylibcudf/rolling.pxd index 5ea7dc747f4..94a6a8a6d89 100644 --- a/python/pylibcudf/pylibcudf/rolling.pxd +++ b/python/pylibcudf/pylibcudf/rolling.pxd @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp cimport bool @@ -8,7 +8,6 @@ from pylibcudf.libcudf.rolling cimport ( bounded_closed, bounded_open, current_row, rolling_request, unbounded ) from pylibcudf.libcudf.types cimport null_order, order, size_type -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from .aggregation cimport Aggregation @@ -63,7 +62,7 @@ cpdef Table grouped_range_rolling_window( PrecedingRangeWindowType preceding, FollowingRangeWindowType following, list requests, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -73,7 +72,7 @@ cpdef Column rolling_window( WindowType following_window, size_type min_periods, Aggregation agg, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -86,6 +85,6 @@ cpdef tuple make_range_windows( null_order null_order, PrecedingRangeWindowType preceding, FollowingRangeWindowType following, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) diff --git a/python/pylibcudf/pylibcudf/rolling.pyi b/python/pylibcudf/pylibcudf/rolling.pyi index 239ce9ddbd8..883f62d0d3f 100644 --- a/python/pylibcudf/pylibcudf/rolling.pyi +++ b/python/pylibcudf/pylibcudf/rolling.pyi @@ -1,14 +1,14 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.aggregation import Aggregation from pylibcudf.column import Column from pylibcudf.scalar import Scalar from pylibcudf.table import Table from pylibcudf.types import DataType, NullOrder, Order +from pylibcudf.utils import CudaStreamLike class Unbounded: ... class CurrentRow: ... @@ -36,7 +36,7 @@ def grouped_range_rolling_window( preceding: RangeWindowType, following: RangeWindowType, requests: list[RollingRequest], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def rolling_window[WindowType: (Column, int)]( @@ -45,7 +45,7 @@ def rolling_window[WindowType: (Column, int)]( following_window: WindowType, min_periods: int, agg: Aggregation, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def is_valid_rolling_aggregation( @@ -58,6 +58,6 @@ def make_range_windows( null_order: NullOrder, preceding: RangeWindowType, following: RangeWindowType, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[Column, Column]: ... diff --git a/python/pylibcudf/pylibcudf/rolling.pyx b/python/pylibcudf/pylibcudf/rolling.pyx index 73c10e53d57..ae9d7665d69 100644 --- a/python/pylibcudf/pylibcudf/rolling.pyx +++ b/python/pylibcudf/pylibcudf/rolling.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from cython.operator cimport dereference @@ -20,6 +20,7 @@ from .column cimport Column from .scalar cimport Scalar from .types cimport DataType from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ @@ -125,7 +126,7 @@ cpdef Table grouped_range_rolling_window( PrecedingRangeWindowType preceding, FollowingRangeWindowType following, list requests, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -164,7 +165,8 @@ cpdef Table grouped_range_rolling_window( for req in requests: crequests.push_back(move((req).view())) - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -176,10 +178,10 @@ cpdef Table grouped_range_rolling_window( dereference(preceding.c_obj.get()), dereference(following.c_obj.get()), crequests, - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(result), stream, mr) + return Table.from_libcudf(move(result), _stream, mr) cpdef Column rolling_window( @@ -188,7 +190,7 @@ cpdef Column rolling_window( WindowType following_window, size_type min_periods, Aggregation agg, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Perform a rolling window operation on a column @@ -224,7 +226,8 @@ cpdef Column rolling_window( # reclaim the GIL internally for just the necessary scope like column.view() cdef const rolling_aggregation *c_agg = agg.view_underlying_as_rolling() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if WindowType is Column: @@ -235,7 +238,7 @@ cpdef Column rolling_window( following_window.view(), min_periods, dereference(c_agg), - stream.view(), + _cs, mr.get_mr() ) else: @@ -246,11 +249,11 @@ cpdef Column rolling_window( following_window, min_periods, dereference(c_agg), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef bool is_valid_rolling_aggregation(DataType source, Aggregation agg): @@ -278,7 +281,7 @@ cpdef tuple make_range_windows( null_order null_order, PrecedingRangeWindowType preceding, FollowingRangeWindowType following, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -308,7 +311,8 @@ cpdef tuple make_range_windows( """ cdef pair[unique_ptr[column], unique_ptr[column]] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -319,10 +323,10 @@ cpdef tuple make_range_windows( null_order, dereference(preceding.c_obj.get()), dereference(following.c_obj.get()), - stream.view(), + _cs, mr.get_mr() ) return ( - Column.from_libcudf(move(result.first), stream, mr), - Column.from_libcudf(move(result.second), stream, mr) + Column.from_libcudf(move(result.first), _stream, mr), + Column.from_libcudf(move(result.second), _stream, mr) ) diff --git a/python/pylibcudf/pylibcudf/round.pxd b/python/pylibcudf/pylibcudf/round.pxd index ecd72c62c0a..0ac0c22346f 100644 --- a/python/pylibcudf/pylibcudf/round.pxd +++ b/python/pylibcudf/pylibcudf/round.pxd @@ -5,7 +5,6 @@ from pylibcudf.libcudf.round cimport rounding_method from .column cimport Column -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource @@ -13,7 +12,7 @@ cpdef Column round( Column source, int32_t decimal_places = *, rounding_method round_method = *, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = * ) @@ -21,6 +20,6 @@ cpdef Column round_decimal( Column source, int32_t decimal_places = *, rounding_method round_method = *, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = * ) diff --git a/python/pylibcudf/pylibcudf/round.pyi b/python/pylibcudf/pylibcudf/round.pyi index 848e43aeda7..30d08f234d5 100644 --- a/python/pylibcudf/pylibcudf/round.pyi +++ b/python/pylibcudf/pylibcudf/round.pyi @@ -4,9 +4,9 @@ from enum import IntEnum from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column +from pylibcudf.utils import CudaStreamLike class RoundingMethod(IntEnum): HALF_UP = ... @@ -16,13 +16,13 @@ def round( source: Column, decimal_places: int = 0, round_method: RoundingMethod = RoundingMethod.HALF_UP, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def round_decimal( source: Column, decimal_places: int = 0, round_method: RoundingMethod = RoundingMethod.HALF_UP, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/round.pyx b/python/pylibcudf/pylibcudf/round.pyx index 84a7ba6dbdf..f5baa6bbd23 100644 --- a/python/pylibcudf/pylibcudf/round.pyx +++ b/python/pylibcudf/pylibcudf/round.pyx @@ -19,6 +19,7 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from .column cimport Column from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["RoundingMethod", "round"] @@ -26,7 +27,7 @@ cpdef Column round( Column source, int32_t decimal_places = 0, rounding_method round_method = rounding_method.HALF_UP, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Rounds all the values in a column to the specified number of decimal places. @@ -58,7 +59,8 @@ cpdef Column round( A Column with values rounded """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -66,18 +68,18 @@ cpdef Column round( source.view(), decimal_places, round_method, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column round_decimal( Column source, int32_t decimal_places = 0, rounding_method round_method = rounding_method.HALF_UP, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """Rounds all the values in a column to the specified number of decimal places. @@ -106,7 +108,8 @@ cpdef Column round_decimal( A Column with values rounded """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -114,10 +117,10 @@ cpdef Column round_decimal( source.view(), decimal_places, round_method, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) RoundingMethod.__str__ = RoundingMethod.__repr__ diff --git a/python/pylibcudf/pylibcudf/scalar.pxd b/python/pylibcudf/pylibcudf/scalar.pxd index 5230c0316be..b628b9185a6 100644 --- a/python/pylibcudf/pylibcudf/scalar.pxd +++ b/python/pylibcudf/pylibcudf/scalar.pxd @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp cimport bool @@ -6,7 +6,6 @@ from libcpp.memory cimport unique_ptr from pylibcudf.libcudf.scalar.scalar cimport scalar from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream from .column cimport Column from .types cimport DataType @@ -24,10 +23,10 @@ cdef class Scalar: cdef const scalar* get(self) noexcept nogil cpdef DataType type(self) - cpdef bool is_valid(self, Stream stream=*) + cpdef bool is_valid(self, object stream = *) @staticmethod - cdef Scalar empty_like(Column column, Stream stream, DeviceMemoryResource mr) + cdef Scalar empty_like(Column column, object stream, DeviceMemoryResource mr) @staticmethod cdef Scalar from_libcudf(unique_ptr[scalar] libcudf_scalar, dtype=*) diff --git a/python/pylibcudf/pylibcudf/scalar.pyi b/python/pylibcudf/pylibcudf/scalar.pyi index ef940d8c021..a204894afd8 100644 --- a/python/pylibcudf/pylibcudf/scalar.pyi +++ b/python/pylibcudf/pylibcudf/scalar.pyi @@ -3,11 +3,10 @@ from typing import Any -from rmm.pylibrmm.stream import Stream - from pylibcudf._interop_helpers import ColumnMetadata from pylibcudf.column import Column from pylibcudf.types import DataType +from pylibcudf.utils import CudaStreamLike NpGeneric = type[Any] @@ -16,31 +15,33 @@ PaScalar = type[Any] class Scalar: def __init__(self): ... def type(self) -> DataType: ... - def is_valid(self, stream: Stream) -> bool: ... + def is_valid(self, stream: CudaStreamLike) -> bool: ... @staticmethod - def empty_like(column: Column, stream: Stream | None = None) -> Scalar: ... + def empty_like( + column: Column, stream: CudaStreamLike | None = None + ) -> Scalar: ... def to_arrow( self, metadata: ColumnMetadata | str | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, ) -> PaScalar: ... @staticmethod def from_arrow( pa_val: Any, dtype: DataType | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, ) -> Scalar: ... @classmethod def from_py( cls, py_val: Any, dtype: DataType | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, ) -> Scalar: ... @classmethod def from_numpy( - cls, np_val: NpGeneric, stream: Stream | None = None + cls, np_val: NpGeneric, stream: CudaStreamLike | None = None ) -> Scalar: ... def to_py( - self, stream: Stream | None = None + self, stream: CudaStreamLike | None = None ) -> None | int | float | str | bool: ... diff --git a/python/pylibcudf/pylibcudf/scalar.pyx b/python/pylibcudf/pylibcudf/scalar.pyx index 8771b4a75fd..54e088787a5 100644 --- a/python/pylibcudf/pylibcudf/scalar.pyx +++ b/python/pylibcudf/pylibcudf/scalar.pyx @@ -57,6 +57,7 @@ from rmm.pylibrmm.memory_resource cimport ( get_current_device_resource, ) from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t from .column cimport Column from .traits cimport is_floating_point @@ -151,10 +152,11 @@ cdef class Scalar: """The type of data in the column.""" return self._data_type - cpdef bool is_valid(self, Stream stream = None): + cpdef bool is_valid(self, object stream = None): """True if the scalar is valid, false if not""" - stream = _get_stream(stream) - return self.get().is_valid(stream.view()) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() + return self.get().is_valid(_cs) def to_arrow( self, @@ -176,7 +178,9 @@ cdef class Scalar: """ # Note that metadata for scalars is primarily important for preserving # information on nested types since names are otherwise irrelevant. - return Column.from_scalar(self, 1, stream).to_arrow(metadata=metadata)[0] + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() + return Column.from_scalar(self, 1, _stream).to_arrow(metadata=metadata)[0] @staticmethod def from_arrow( @@ -205,7 +209,7 @@ cdef class Scalar: return _from_arrow(pa_val, dtype, stream) @staticmethod - cdef Scalar empty_like(Column column, Stream stream, DeviceMemoryResource mr): + cdef Scalar empty_like(Column column, object stream, DeviceMemoryResource mr): """Construct a null scalar with the same type as column. Parameters @@ -221,8 +225,10 @@ cdef class Scalar: ------- New empty (null) scalar of the given type. """ + cdef Stream _stream = stream + cdef cudaStream_t _cs = _stream.view().value() return Scalar.from_libcudf( - move(make_empty_scalar_like(column.view(), stream.view(), mr.get_mr())) + move(make_empty_scalar_like(column.view(), _cs, mr.get_mr())) ) @staticmethod @@ -266,9 +272,10 @@ cdef class Scalar: Scalar New pylibcudf.Scalar """ - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) - return _from_py(py_val, dtype, stream, mr) + return _from_py(py_val, dtype, _stream, mr) @classmethod def from_numpy( @@ -294,9 +301,10 @@ cdef class Scalar: Scalar New pylibcudf.Scalar """ - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) - return _from_numpy(np_val, stream, mr) + return _from_numpy(np_val, _stream, mr) def to_py(self, stream: Stream | None = None): """ @@ -312,39 +320,40 @@ cdef class Scalar: Python scalar A Python scalar associated with the type of the Scalar. """ - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() if not self.is_valid(stream): return None cdef type_id tid = self.type().id() cdef const scalar* slr = self.c_obj.get() if tid == type_id.BOOL8: - return (slr).value(stream.view()) + return (slr).value(_cs) elif tid == type_id.STRING: - return (slr).to_string(stream.view()).decode() + return (slr).to_string(_cs).decode() elif tid == type_id.FLOAT32: - return (slr).value(stream.view()) + return (slr).value(_cs) elif tid == type_id.FLOAT64: - return (slr).value(stream.view()) + return (slr).value(_cs) elif tid == type_id.INT8: - return (slr).value(stream.view()) + return (slr).value(_cs) elif tid == type_id.INT16: - return (slr).value(stream.view()) + return (slr).value(_cs) elif tid == type_id.INT32: - return (slr).value(stream.view()) + return (slr).value(_cs) elif tid == type_id.INT64: - return (slr).value(stream.view()) + return (slr).value(_cs) elif tid == type_id.UINT8: - return (slr).value(stream.view()) + return (slr).value(_cs) elif tid == type_id.UINT16: - return (slr).value(stream.view()) + return (slr).value(_cs) elif tid == type_id.UINT32: - return (slr).value(stream.view()) + return (slr).value(_cs) elif tid == type_id.UINT64: - return (slr).value(stream.view()) + return (slr).value(_cs) elif tid == type_id.DECIMAL128: return decimal.Decimal( - (slr).value(stream.view()).value() + (slr).value(_cs).value() ).scaleb( (slr).type().scale() ) @@ -375,6 +384,8 @@ def _from_py( def _( py_val, dtype: DataType | None, stream: Stream, mr: DeviceMemoryResource ): + cdef Stream _stream = stream + cdef cudaStream_t _cs = _stream.view().value() cdef DataType c_dtype if dtype is None: raise ValueError("Must specify a dtype for a None value.") @@ -382,7 +393,7 @@ def _( c_dtype = dtype cdef unique_ptr[scalar] c_obj = make_default_constructed_scalar( c_dtype.c_obj, - stream.view(), + _cs, mr.get_mr() ) return _new_scalar(move(c_obj), dtype) @@ -402,6 +413,8 @@ def _( def _( py_val, dtype: DataType | None, stream: Stream, mr: DeviceMemoryResource ): + cdef Stream _stream = stream + cdef cudaStream_t _cs = _stream.view().value() cdef unique_ptr[scalar] c_obj cdef DataType c_dtype if dtype is None: @@ -414,11 +427,11 @@ def _( if tid == type_id.FLOAT32: if abs(py_val) > numeric_limits[float].max(): raise OverflowError(f"{py_val} out of range for FLOAT32 scalar") - c_obj = make_numeric_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) - (c_obj.get()).set_value(py_val, stream.view()) + c_obj = make_numeric_scalar(c_dtype.c_obj, _cs, mr.get_mr()) + (c_obj.get()).set_value(py_val, _cs) elif tid == type_id.FLOAT64: - c_obj = make_numeric_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) - (c_obj.get()).set_value(py_val, stream.view()) + c_obj = make_numeric_scalar(c_dtype.c_obj, _cs, mr.get_mr()) + (c_obj.get()).set_value(py_val, _cs) else: typ = c_dtype.id() raise TypeError(f"Cannot convert float to Scalar with dtype {typ.name}") @@ -430,6 +443,8 @@ def _( def _( py_val, dtype: DataType | None, stream: Stream, mr: DeviceMemoryResource ): + cdef Stream _stream = stream + cdef cudaStream_t _cs = _stream.view().value() cdef unique_ptr[scalar] c_obj cdef DataType c_dtype cdef duration_ns c_duration_ns @@ -440,7 +455,7 @@ def _( if dtype is None: c_dtype = dtype = DataType(type_id.INT64) elif is_floating_point(dtype): - return _from_py(float(py_val), dtype, stream, mr) + return _from_py(float(py_val), dtype, _stream, mr) else: c_dtype = dtype cdef type_id tid = c_dtype.id() @@ -450,80 +465,80 @@ def _( numeric_limits[int8_t].min() <= py_val <= numeric_limits[int8_t].max() ): raise OverflowError(f"{py_val} out of range for INT8 scalar") - c_obj = make_numeric_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) - (c_obj.get()).set_value(py_val, stream.view()) + c_obj = make_numeric_scalar(c_dtype.c_obj, _cs, mr.get_mr()) + (c_obj.get()).set_value(py_val, _cs) elif tid == type_id.INT16: if not ( numeric_limits[int16_t].min() <= py_val <= numeric_limits[int16_t].max() ): raise OverflowError(f"{py_val} out of range for INT16 scalar") - c_obj = make_numeric_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) - (c_obj.get()).set_value(py_val, stream.view()) + c_obj = make_numeric_scalar(c_dtype.c_obj, _cs, mr.get_mr()) + (c_obj.get()).set_value(py_val, _cs) elif tid == type_id.INT32: if not ( numeric_limits[int32_t].min() <= py_val <= numeric_limits[int32_t].max() ): raise OverflowError(f"{py_val} out of range for INT32 scalar") - c_obj = make_numeric_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) - (c_obj.get()).set_value(py_val, stream.view()) + c_obj = make_numeric_scalar(c_dtype.c_obj, _cs, mr.get_mr()) + (c_obj.get()).set_value(py_val, _cs) elif tid == type_id.INT64: if not ( numeric_limits[int64_t].min() <= py_val <= numeric_limits[int64_t].max() ): raise OverflowError(f"{py_val} out of range for INT64 scalar") - c_obj = make_numeric_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) - (c_obj.get()).set_value(py_val, stream.view()) + c_obj = make_numeric_scalar(c_dtype.c_obj, _cs, mr.get_mr()) + (c_obj.get()).set_value(py_val, _cs) elif tid == type_id.UINT8: if py_val < 0: raise ValueError("Cannot assign negative value to UINT8 scalar") if py_val > numeric_limits[uint8_t].max(): raise OverflowError(f"{py_val} out of range for UINT8 scalar") - c_obj = make_numeric_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) - (c_obj.get()).set_value(py_val, stream.view()) + c_obj = make_numeric_scalar(c_dtype.c_obj, _cs, mr.get_mr()) + (c_obj.get()).set_value(py_val, _cs) elif tid == type_id.UINT16: if py_val < 0: raise ValueError("Cannot assign negative value to UINT16 scalar") if py_val > numeric_limits[uint16_t].max(): raise OverflowError(f"{py_val} out of range for UINT16 scalar") - c_obj = make_numeric_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) - (c_obj.get()).set_value(py_val, stream.view()) + c_obj = make_numeric_scalar(c_dtype.c_obj, _cs, mr.get_mr()) + (c_obj.get()).set_value(py_val, _cs) elif tid == type_id.UINT32: if py_val < 0: raise ValueError("Cannot assign negative value to UINT32 scalar") if py_val > numeric_limits[uint32_t].max(): raise OverflowError(f"{py_val} out of range for UINT32 scalar") - c_obj = make_numeric_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) - (c_obj.get()).set_value(py_val, stream.view()) + c_obj = make_numeric_scalar(c_dtype.c_obj, _cs, mr.get_mr()) + (c_obj.get()).set_value(py_val, _cs) elif tid == type_id.UINT64: if py_val < 0: raise ValueError("Cannot assign negative value to UINT64 scalar") if py_val > numeric_limits[uint64_t].max(): raise OverflowError(f"{py_val} out of range for UINT64 scalar") - c_obj = make_numeric_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) - (c_obj.get()).set_value(py_val, stream.view()) + c_obj = make_numeric_scalar(c_dtype.c_obj, _cs, mr.get_mr()) + (c_obj.get()).set_value(py_val, _cs) elif tid == type_id.BOOL8: if py_val not in (0, 1): raise ValueError(f"Cannot convert {py_val} to BOOL8 scalar") - c_obj = make_numeric_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) - (c_obj.get()).set_value(py_val != 0, stream.view()) + c_obj = make_numeric_scalar(c_dtype.c_obj, _cs, mr.get_mr()) + (c_obj.get()).set_value(py_val != 0, _cs) elif tid == type_id.DURATION_NANOSECONDS: if py_val > numeric_limits[int64_t].max(): raise OverflowError( f"{py_val} nanoseconds out of range for INT64 limit." ) - c_obj = make_duration_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) + c_obj = make_duration_scalar(c_dtype.c_obj, _cs, mr.get_mr()) c_duration_ns = duration_ns(py_val) (c_obj.get()).set_value( - c_duration_ns, stream.view() + c_duration_ns, _cs ) elif tid == type_id.DURATION_MICROSECONDS: @@ -531,10 +546,10 @@ def _( raise OverflowError( f"{py_val} microseconds out of range for INT64 limit." ) - c_obj = make_duration_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) + c_obj = make_duration_scalar(c_dtype.c_obj, _cs, mr.get_mr()) c_duration_us = duration_us(py_val) (c_obj.get()).set_value( - c_duration_us, stream.view() + c_duration_us, _cs ) elif tid == type_id.DURATION_MILLISECONDS: @@ -542,10 +557,10 @@ def _( raise OverflowError( f"{py_val} milliseconds out of range for INT64 limit." ) - c_obj = make_duration_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) + c_obj = make_duration_scalar(c_dtype.c_obj, _cs, mr.get_mr()) c_duration_ms = duration_ms(py_val) (c_obj.get()).set_value( - c_duration_ms, stream.view() + c_duration_ms, _cs ) elif tid == type_id.DURATION_SECONDS: @@ -553,10 +568,10 @@ def _( raise OverflowError( f"{py_val} seconds out of range for INT64 limit." ) - c_obj = make_duration_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) + c_obj = make_duration_scalar(c_dtype.c_obj, _cs, mr.get_mr()) c_duration_s = duration_s(py_val) (c_obj.get()).set_value( - c_duration_s, stream.view() + c_duration_s, _cs ) elif tid == type_id.DURATION_DAYS: @@ -564,10 +579,10 @@ def _( raise OverflowError( f"{py_val} days out of range for INT32 limit." ) - c_obj = make_duration_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) + c_obj = make_duration_scalar(c_dtype.c_obj, _cs, mr.get_mr()) c_duration_D = duration_D(py_val) (c_obj.get()).set_value( - c_duration_D, stream.view() + c_duration_D, _cs ) else: @@ -581,6 +596,8 @@ def _( def _( py_val, dtype: DataType | None, stream: Stream, mr: DeviceMemoryResource ): + cdef Stream _stream = stream + cdef cudaStream_t _cs = _stream.view().value() if dtype is None: dtype = DataType(type_id.BOOL8) elif dtype.id() != type_id.BOOL8: @@ -591,10 +608,10 @@ def _( cdef unique_ptr[scalar] c_obj = make_numeric_scalar( (dtype).c_obj, - stream.view(), + _cs, mr.get_mr() ) - (c_obj.get()).set_value(py_val, stream.view()) + (c_obj.get()).set_value(py_val, _cs) return _new_scalar(move(c_obj), dtype) @@ -602,6 +619,8 @@ def _( def _( py_val, dtype: DataType | None, stream: Stream, mr: DeviceMemoryResource ): + cdef Stream _stream = stream + cdef cudaStream_t _cs = _stream.view().value() if dtype is None: dtype = DataType(type_id.STRING) elif dtype.id() != type_id.STRING: @@ -610,7 +629,7 @@ def _( f"Cannot convert str to Scalar with dtype {tid.name}" ) cdef unique_ptr[scalar] c_obj = make_string_scalar( - py_val.encode(), stream.view(), mr.get_mr() + py_val.encode(), _cs, mr.get_mr() ) return _new_scalar(move(c_obj), dtype) @@ -619,6 +638,8 @@ def _( def _( py_val, dtype: DataType | None, stream: Stream, mr: DeviceMemoryResource ): + cdef Stream _stream = stream + cdef cudaStream_t _cs = _stream.view().value() cdef unique_ptr[scalar] c_obj cdef duration_us c_duration_us cdef duration_ns c_duration_ns @@ -637,10 +658,10 @@ def _( raise OverflowError( f"{total_nanoseconds} nanoseconds out of range for INT64 limit." ) - c_obj = make_duration_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) + c_obj = make_duration_scalar(c_dtype.c_obj, _cs, mr.get_mr()) c_duration_ns = duration_ns(total_nanoseconds) (c_obj.get()).set_value( - c_duration_ns, stream.view() + c_duration_ns, _cs ) elif tid == type_id.DURATION_MICROSECONDS: total_microseconds = int(total_seconds * 1_000_000) @@ -648,10 +669,10 @@ def _( raise OverflowError( f"{total_microseconds} microseconds out of range for INT64 limit." ) - c_obj = make_duration_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) + c_obj = make_duration_scalar(c_dtype.c_obj, _cs, mr.get_mr()) c_duration_us = duration_us(total_microseconds) (c_obj.get()).set_value( - c_duration_us, stream.view() + c_duration_us, _cs ) elif tid == type_id.DURATION_MILLISECONDS: total_milliseconds = int(total_seconds * 1_000) @@ -659,10 +680,10 @@ def _( raise OverflowError( f"{total_milliseconds} milliseconds out of range for INT64 limit." ) - c_obj = make_duration_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) + c_obj = make_duration_scalar(c_dtype.c_obj, _cs, mr.get_mr()) c_duration_ms = duration_ms(total_milliseconds) (c_obj.get()).set_value( - c_duration_ms, stream.view() + c_duration_ms, _cs ) elif tid == type_id.DURATION_SECONDS: total_seconds = int(total_seconds) @@ -670,10 +691,10 @@ def _( raise OverflowError( f"{total_seconds} seconds out of range for INT64 limit." ) - c_obj = make_duration_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) + c_obj = make_duration_scalar(c_dtype.c_obj, _cs, mr.get_mr()) c_duration_s = duration_s(total_seconds) (c_obj.get()).set_value( - c_duration_s, stream.view() + c_duration_s, _cs ) elif tid == type_id.DURATION_DAYS: total_days = int(total_seconds // 86400) @@ -681,10 +702,10 @@ def _( raise OverflowError( f"{total_days} days out of range for INT32 limit." ) - c_obj = make_duration_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) + c_obj = make_duration_scalar(c_dtype.c_obj, _cs, mr.get_mr()) c_duration_D = duration_D(total_days) (c_obj.get()).set_value( - c_duration_D, stream.view() + c_duration_D, _cs ) else: typ = c_dtype.id() @@ -696,6 +717,8 @@ def _( def _( py_val, dtype: DataType | None, stream: Stream, mr: DeviceMemoryResource ): + cdef Stream _stream = stream + cdef cudaStream_t _cs = _stream.view().value() cdef unique_ptr[scalar] c_obj cdef duration_us c_duration_us cdef duration_ns c_duration_ns @@ -727,11 +750,11 @@ def _( raise OverflowError( f"{epoch_nanoseconds} nanoseconds out of range for INT64 limit." ) - c_obj = make_timestamp_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) + c_obj = make_timestamp_scalar(c_dtype.c_obj, _cs, mr.get_mr()) c_duration_ns = duration_ns(epoch_nanoseconds) c_timestamp_ns = timestamp_ns(c_duration_ns) (c_obj.get()).set_value( - c_timestamp_ns, stream.view() + c_timestamp_ns, _cs ) elif tid == type_id.TIMESTAMP_MICROSECONDS: epoch_microseconds = int(epoch_seconds * 1_000_000) @@ -739,11 +762,11 @@ def _( raise OverflowError( f"{epoch_microseconds} microseconds out of range for INT64 limit." ) - c_obj = make_timestamp_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) + c_obj = make_timestamp_scalar(c_dtype.c_obj, _cs, mr.get_mr()) c_duration_us = duration_us(epoch_microseconds) c_timestamp_us = timestamp_us(c_duration_us) (c_obj.get()).set_value( - c_timestamp_us, stream.view() + c_timestamp_us, _cs ) elif tid == type_id.TIMESTAMP_MILLISECONDS: epoch_milliseconds = int(epoch_seconds * 1_000) @@ -751,11 +774,11 @@ def _( raise OverflowError( f"{epoch_milliseconds} milliseconds out of range for INT64 limit." ) - c_obj = make_timestamp_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) + c_obj = make_timestamp_scalar(c_dtype.c_obj, _cs, mr.get_mr()) c_duration_ms = duration_ms(epoch_milliseconds) c_timestamp_ms = timestamp_ms(c_duration_ms) (c_obj.get()).set_value( - c_timestamp_ms, stream.view() + c_timestamp_ms, _cs ) elif tid == type_id.TIMESTAMP_SECONDS: epoch_seconds = int(epoch_seconds) @@ -763,11 +786,11 @@ def _( raise OverflowError( f"{epoch_seconds} seconds out of range for INT64 limit." ) - c_obj = make_timestamp_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) + c_obj = make_timestamp_scalar(c_dtype.c_obj, _cs, mr.get_mr()) c_duration_s = duration_s(epoch_seconds) c_timestamp_s = timestamp_s(c_duration_s) (c_obj.get()).set_value( - c_timestamp_s, stream.view() + c_timestamp_s, _cs ) elif tid == type_id.TIMESTAMP_DAYS: epoch_days = int(epoch_seconds // 86400) @@ -775,11 +798,11 @@ def _( raise OverflowError( f"{epoch_days} days out of range for INT32 limit." ) - c_obj = make_timestamp_scalar(c_dtype.c_obj, stream.view(), mr.get_mr()) + c_obj = make_timestamp_scalar(c_dtype.c_obj, _cs, mr.get_mr()) c_duration_D = duration_D(epoch_days) c_timestamp_D = timestamp_D(c_duration_D) (c_obj.get()).set_value( - c_timestamp_D, stream.view() + c_timestamp_D, _cs ) else: typ = c_dtype.id() @@ -791,6 +814,8 @@ def _( def _( py_val, dtype: DataType | None, stream: Stream, mr: DeviceMemoryResource ): + cdef Stream _stream = stream + cdef cudaStream_t _cs = _stream.view().value() scale = py_val.as_tuple().exponent as_int = int(py_val.scaleb(-scale)) @@ -804,7 +829,7 @@ def _( cdef unique_ptr[scalar] c_obj = make_fixed_point_scalar[decimal128]( val, scale_type(scale), - stream.view(), + _cs, mr.get_mr() ) return _new_scalar(move(c_obj), dtype) @@ -829,21 +854,25 @@ if np is not None: @_from_numpy.register(np.bool_) def _(np_val, stream: Stream, mr: DeviceMemoryResource): + cdef Stream _stream = stream + cdef cudaStream_t _cs = _stream.view().value() cdef DataType dtype = DataType(type_id.BOOL8) cdef unique_ptr[scalar] c_obj = make_numeric_scalar( - dtype.c_obj, stream.view(), mr.get_mr() + dtype.c_obj, _cs, mr.get_mr() ) cdef cbool c_val = np_val - (c_obj.get()).set_value(c_val, stream.view()) + (c_obj.get()).set_value(c_val, _cs) cdef Scalar slr = _new_scalar(move(c_obj), dtype) return slr @_from_numpy.register(np.str_) def _(np_val, stream: Stream, mr: DeviceMemoryResource): + cdef Stream _stream = stream + cdef cudaStream_t _cs = _stream.view().value() cdef DataType dtype = DataType(type_id.STRING) cdef unique_ptr[scalar] c_obj = make_string_scalar( np_val.item().encode(), - stream.view(), + _cs, mr.get_mr() ) cdef Scalar slr = _new_scalar(move(c_obj), dtype) @@ -851,101 +880,121 @@ if np is not None: @_from_numpy.register(np.int8) def _(np_val, stream: Stream, mr: DeviceMemoryResource): + cdef Stream _stream = stream + cdef cudaStream_t _cs = _stream.view().value() dtype = DataType(type_id.INT8) cdef unique_ptr[scalar] c_obj = make_numeric_scalar( - dtype.c_obj, stream.view(), mr.get_mr() + dtype.c_obj, _cs, mr.get_mr() ) - (c_obj.get()).set_value(np_val, stream.view()) + (c_obj.get()).set_value(np_val, _cs) cdef Scalar slr = _new_scalar(move(c_obj), dtype) return slr @_from_numpy.register(np.int16) def _(np_val, stream: Stream, mr: DeviceMemoryResource): + cdef Stream _stream = stream + cdef cudaStream_t _cs = _stream.view().value() dtype = DataType(type_id.INT16) cdef unique_ptr[scalar] c_obj = make_numeric_scalar( - dtype.c_obj, stream.view(), mr.get_mr() + dtype.c_obj, _cs, mr.get_mr() ) - (c_obj.get()).set_value(np_val, stream.view()) + (c_obj.get()).set_value(np_val, _cs) cdef Scalar slr = _new_scalar(move(c_obj), dtype) return slr @_from_numpy.register(np.int32) def _(np_val, stream: Stream, mr: DeviceMemoryResource): + cdef Stream _stream = stream + cdef cudaStream_t _cs = _stream.view().value() dtype = DataType(type_id.INT32) cdef unique_ptr[scalar] c_obj = make_numeric_scalar( - dtype.c_obj, stream.view(), mr.get_mr() + dtype.c_obj, _cs, mr.get_mr() ) - (c_obj.get()).set_value(np_val, stream.view()) + (c_obj.get()).set_value(np_val, _cs) cdef Scalar slr = _new_scalar(move(c_obj), dtype) return slr @_from_numpy.register(np.int64) def _(np_val, stream: Stream, mr: DeviceMemoryResource): + cdef Stream _stream = stream + cdef cudaStream_t _cs = _stream.view().value() dtype = DataType(type_id.INT64) cdef unique_ptr[scalar] c_obj = make_numeric_scalar( - dtype.c_obj, stream.view(), mr.get_mr() + dtype.c_obj, _cs, mr.get_mr() ) - (c_obj.get()).set_value(np_val, stream.view()) + (c_obj.get()).set_value(np_val, _cs) cdef Scalar slr = _new_scalar(move(c_obj), dtype) return slr @_from_numpy.register(np.uint8) def _(np_val, stream: Stream, mr: DeviceMemoryResource): + cdef Stream _stream = stream + cdef cudaStream_t _cs = _stream.view().value() dtype = DataType(type_id.UINT8) cdef unique_ptr[scalar] c_obj = make_numeric_scalar( - dtype.c_obj, stream.view(), mr.get_mr() + dtype.c_obj, _cs, mr.get_mr() ) - (c_obj.get()).set_value(np_val, stream.view()) + (c_obj.get()).set_value(np_val, _cs) cdef Scalar slr = _new_scalar(move(c_obj), dtype) return slr @_from_numpy.register(np.uint16) def _(np_val, stream: Stream, mr: DeviceMemoryResource): + cdef Stream _stream = stream + cdef cudaStream_t _cs = _stream.view().value() dtype = DataType(type_id.UINT16) cdef unique_ptr[scalar] c_obj = make_numeric_scalar( - dtype.c_obj, stream.view(), mr.get_mr() + dtype.c_obj, _cs, mr.get_mr() ) - (c_obj.get()).set_value(np_val, stream.view()) + (c_obj.get()).set_value(np_val, _cs) cdef Scalar slr = _new_scalar(move(c_obj), dtype) return slr @_from_numpy.register(np.uint32) def _(np_val, stream: Stream, mr: DeviceMemoryResource): + cdef Stream _stream = stream + cdef cudaStream_t _cs = _stream.view().value() dtype = DataType(type_id.UINT32) cdef unique_ptr[scalar] c_obj = make_numeric_scalar( - dtype.c_obj, stream.view(), mr.get_mr() + dtype.c_obj, _cs, mr.get_mr() ) - (c_obj.get()).set_value(np_val, stream.view()) + (c_obj.get()).set_value(np_val, _cs) cdef Scalar slr = _new_scalar(move(c_obj), dtype) return slr @_from_numpy.register(np.uint64) def _(np_val, stream: Stream, mr: DeviceMemoryResource): + cdef Stream _stream = stream + cdef cudaStream_t _cs = _stream.view().value() dtype = DataType(type_id.UINT64) cdef unique_ptr[scalar] c_obj = make_numeric_scalar( - dtype.c_obj, stream.view(), mr.get_mr() + dtype.c_obj, _cs, mr.get_mr() ) - (c_obj.get()).set_value(np_val, stream.view()) + (c_obj.get()).set_value(np_val, _cs) cdef Scalar slr = _new_scalar(move(c_obj), dtype) return slr @_from_numpy.register(np.float32) def _(np_val, stream: Stream, mr: DeviceMemoryResource): + cdef Stream _stream = stream + cdef cudaStream_t _cs = _stream.view().value() dtype = DataType(type_id.FLOAT32) cdef unique_ptr[scalar] c_obj = make_numeric_scalar( - dtype.c_obj, stream.view(), mr.get_mr() + dtype.c_obj, _cs, mr.get_mr() ) - (c_obj.get()).set_value(np_val, stream.view()) + (c_obj.get()).set_value(np_val, _cs) cdef Scalar slr = _new_scalar(move(c_obj), dtype) return slr @_from_numpy.register(np.float64) def _(np_val, stream: Stream, mr: DeviceMemoryResource): + cdef Stream _stream = stream + cdef cudaStream_t _cs = _stream.view().value() dtype = DataType(type_id.FLOAT64) cdef unique_ptr[scalar] c_obj = make_numeric_scalar( - dtype.c_obj, stream.view(), mr.get_mr() + dtype.c_obj, _cs, mr.get_mr() ) - (c_obj.get()).set_value(np_val, stream.view()) + (c_obj.get()).set_value(np_val, _cs) cdef Scalar slr = _new_scalar(move(c_obj), dtype) return slr diff --git a/python/pylibcudf/pylibcudf/search.pxd b/python/pylibcudf/pylibcudf/search.pxd index 7b0725bf60b..c26a6689240 100644 --- a/python/pylibcudf/pylibcudf/search.pxd +++ b/python/pylibcudf/pylibcudf/search.pxd @@ -1,7 +1,6 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from .column cimport Column @@ -13,7 +12,7 @@ cpdef Column lower_bound( Table needles, list column_order, list null_precedence, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -22,10 +21,10 @@ cpdef Column upper_bound( Table needles, list column_order, list null_precedence, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) cpdef Column contains( - Column haystack, Column needles, Stream stream = *, DeviceMemoryResource mr = * + Column haystack, Column needles, object stream = *, DeviceMemoryResource mr = * ) diff --git a/python/pylibcudf/pylibcudf/search.pyi b/python/pylibcudf/pylibcudf/search.pyi index eaec283a32a..6cc58946f56 100644 --- a/python/pylibcudf/pylibcudf/search.pyi +++ b/python/pylibcudf/pylibcudf/search.pyi @@ -1,19 +1,19 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.table import Table from pylibcudf.types import NullOrder, Order +from pylibcudf.utils import CudaStreamLike def lower_bound( haystack: Table, needles: Table, column_order: list[Order], null_precedence: list[NullOrder], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def upper_bound( @@ -21,12 +21,12 @@ def upper_bound( needles: Table, column_order: list[Order], null_precedence: list[NullOrder], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def contains( haystack: Column, needles: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/search.pyx b/python/pylibcudf/pylibcudf/search.pyx index 4915b1b8be9..885d25f2d49 100644 --- a/python/pylibcudf/pylibcudf/search.pyx +++ b/python/pylibcudf/pylibcudf/search.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -13,6 +13,7 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from .column cimport Column from .table cimport Table from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["contains", "lower_bound", "upper_bound"] @@ -21,7 +22,7 @@ cpdef Column lower_bound( Table needles, list column_order, list null_precedence, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Find smallest indices in haystack where needles may be inserted to retain order. @@ -52,7 +53,8 @@ cpdef Column lower_bound( cdef vector[order] c_orders = column_order cdef vector[null_order] c_null_precedence = null_precedence - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -61,10 +63,10 @@ cpdef Column lower_bound( needles.view(), c_orders, c_null_precedence, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column upper_bound( @@ -72,7 +74,7 @@ cpdef Column upper_bound( Table needles, list column_order, list null_precedence, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Find largest indices in haystack where needles may be inserted to retain order. @@ -103,7 +105,8 @@ cpdef Column upper_bound( cdef vector[order] c_orders = column_order cdef vector[null_order] c_null_precedence = null_precedence - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -112,14 +115,14 @@ cpdef Column upper_bound( needles.view(), c_orders, c_null_precedence, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column contains( - Column haystack, Column needles, Stream stream=None, DeviceMemoryResource mr=None + Column haystack, Column needles, object stream=None, DeviceMemoryResource mr=None ): """Check whether needles are present in haystack. @@ -143,14 +146,15 @@ cpdef Column contains( """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_search.contains( haystack.view(), needles.view(), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/sorting.pxd b/python/pylibcudf/pylibcudf/sorting.pxd index 701b6803c34..a081ece747a 100644 --- a/python/pylibcudf/pylibcudf/sorting.pxd +++ b/python/pylibcudf/pylibcudf/sorting.pxd @@ -1,11 +1,10 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp cimport bool from pylibcudf.libcudf.aggregation cimport rank_method from pylibcudf.libcudf.types cimport null_order, null_policy, order, size_type from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream from .column cimport Column from .table cimport Table @@ -15,7 +14,7 @@ cpdef Column sorted_order( Table source_table, list column_order, list null_precedence, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -23,7 +22,7 @@ cpdef Column stable_sorted_order( Table source_table, list column_order, list null_precedence, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -34,12 +33,12 @@ cpdef Column rank( null_policy null_handling, null_order null_precedence, bool percentage, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef bool is_sorted( - Table table, list column_order, list null_precedence, Stream stream=* + Table table, list column_order, list null_precedence, object stream = * ) cpdef Table segmented_sort_by_key( @@ -48,7 +47,7 @@ cpdef Table segmented_sort_by_key( Column segment_offsets, list column_order, list null_precedence, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -58,7 +57,7 @@ cpdef Table stable_segmented_sort_by_key( Column segment_offsets, list column_order, list null_precedence, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -67,7 +66,7 @@ cpdef Table sort_by_key( Table keys, list column_order, list null_precedence, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -76,7 +75,7 @@ cpdef Table stable_sort_by_key( Table keys, list column_order, list null_precedence, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -84,7 +83,7 @@ cpdef Table sort( Table source_table, list column_order, list null_precedence, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -92,7 +91,7 @@ cpdef Table stable_sort( Table source_table, list column_order, list null_precedence, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -100,7 +99,7 @@ cpdef Column top_k( Column col, size_type k, order sort_order=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -108,6 +107,6 @@ cpdef Column top_k_order( Column col, size_type k, order sort_order=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) diff --git a/python/pylibcudf/pylibcudf/sorting.pyi b/python/pylibcudf/pylibcudf/sorting.pyi index 8f00fcade6e..a06586a8f39 100644 --- a/python/pylibcudf/pylibcudf/sorting.pyi +++ b/python/pylibcudf/pylibcudf/sorting.pyi @@ -1,26 +1,26 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.aggregation import RankMethod from pylibcudf.column import Column from pylibcudf.table import Table from pylibcudf.types import NullOrder, NullPolicy, Order +from pylibcudf.utils import CudaStreamLike def sorted_order( source_table: Table, column_order: list[Order], null_precedence: list[NullOrder], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def stable_sorted_order( source_table: Table, column_order: list[Order], null_precedence: list[NullOrder], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def rank( @@ -30,14 +30,14 @@ def rank( null_handling: NullPolicy, null_precedence: NullOrder, percentage: bool, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def is_sorted( tbl: Table, column_order: list[Order], null_precedence: list[NullOrder], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, ) -> bool: ... def segmented_sort_by_key( values: Table, @@ -45,7 +45,7 @@ def segmented_sort_by_key( segment_offsets: Column, column_order: list[Order], null_precedence: list[NullOrder], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def stable_segmented_sort_by_key( @@ -54,7 +54,7 @@ def stable_segmented_sort_by_key( segment_offsets: Column, column_order: list[Order], null_precedence: list[NullOrder], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def sort_by_key( @@ -62,7 +62,7 @@ def sort_by_key( keys: Table, column_order: list[Order], null_precedence: list[NullOrder], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def stable_sort_by_key( @@ -70,34 +70,34 @@ def stable_sort_by_key( keys: Table, column_order: list[Order], null_precedence: list[NullOrder], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def sort( source_table: Table, column_order: list[Order], null_precedence: list[NullOrder], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def stable_sort( source_table: Table, column_order: list[Order], null_precedence: list[NullOrder], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def top_k( col: Column, k: int, sort_order: Order = Order.DESCENDING, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def top_k_order( col: Column, k: int, sort_order: Order = Order.DESCENDING, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/sorting.pyx b/python/pylibcudf/pylibcudf/sorting.pyx index be668ff2526..fa0ed78b709 100644 --- a/python/pylibcudf/pylibcudf/sorting.pyx +++ b/python/pylibcudf/pylibcudf/sorting.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -15,6 +15,7 @@ from rmm.pylibrmm.stream cimport Stream from .column cimport Column from .table cimport Table from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "is_sorted", @@ -33,7 +34,7 @@ cpdef Column sorted_order( Table source_table, list column_order, list null_precedence, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Computes the row indices required to sort the table. @@ -58,7 +59,8 @@ cpdef Column sorted_order( cdef vector[order] c_orders = column_order cdef vector[null_order] c_null_precedence = null_precedence - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -66,17 +68,17 @@ cpdef Column sorted_order( source_table.view(), c_orders, c_null_precedence, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column stable_sorted_order( Table source_table, list column_order, list null_precedence, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Computes the row indices required to sort the table, @@ -102,7 +104,8 @@ cpdef Column stable_sorted_order( cdef vector[order] c_orders = column_order cdef vector[null_order] c_null_precedence = null_precedence - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -110,10 +113,10 @@ cpdef Column stable_sorted_order( source_table.view(), c_orders, c_null_precedence, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column rank( @@ -123,7 +126,7 @@ cpdef Column rank( null_policy null_handling, null_order null_precedence, bool percentage, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Computes the rank of each element in the column. @@ -152,7 +155,8 @@ cpdef Column rank( """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -163,14 +167,14 @@ cpdef Column rank( null_handling, null_precedence, percentage, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef bool is_sorted( - Table tbl, list column_order, list null_precedence, Stream stream=None + Table tbl, list column_order, list null_precedence, object stream=None ): """Checks if the table is sorted. @@ -194,14 +198,15 @@ cpdef bool is_sorted( cdef vector[order] c_orders = column_order cdef vector[null_order] c_null_precedence = null_precedence - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() with nogil: c_result = cpp_sorting.is_sorted( tbl.view(), c_orders, c_null_precedence, - stream.view() + _cs ) return c_result @@ -212,7 +217,7 @@ cpdef Table segmented_sort_by_key( Column segment_offsets, list column_order, list null_precedence, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Sorts the table by key, within segments. @@ -241,7 +246,8 @@ cpdef Table segmented_sort_by_key( cdef vector[order] c_orders = column_order cdef vector[null_order] c_null_precedence = null_precedence - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -251,10 +257,10 @@ cpdef Table segmented_sort_by_key( segment_offsets.view(), c_orders, c_null_precedence, - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef Table stable_segmented_sort_by_key( @@ -263,7 +269,7 @@ cpdef Table stable_segmented_sort_by_key( Column segment_offsets, list column_order, list null_precedence, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Sorts the table by key preserving order of equal elements, @@ -293,7 +299,8 @@ cpdef Table stable_segmented_sort_by_key( cdef vector[order] c_orders = column_order cdef vector[null_order] c_null_precedence = null_precedence - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -303,10 +310,10 @@ cpdef Table stable_segmented_sort_by_key( segment_offsets.view(), c_orders, c_null_precedence, - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef Table sort_by_key( @@ -314,7 +321,7 @@ cpdef Table sort_by_key( Table keys, list column_order, list null_precedence, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Sorts the table by key. @@ -341,7 +348,8 @@ cpdef Table sort_by_key( cdef vector[order] c_orders = column_order cdef vector[null_order] c_null_precedence = null_precedence - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -350,10 +358,10 @@ cpdef Table sort_by_key( keys.view(), c_orders, c_null_precedence, - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef Table stable_sort_by_key( @@ -361,7 +369,7 @@ cpdef Table stable_sort_by_key( Table keys, list column_order, list null_precedence, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Sorts the table by key preserving order of equal elements. @@ -388,7 +396,8 @@ cpdef Table stable_sort_by_key( cdef vector[order] c_orders = column_order cdef vector[null_order] c_null_precedence = null_precedence - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -397,17 +406,17 @@ cpdef Table stable_sort_by_key( keys.view(), c_orders, c_null_precedence, - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef Table sort( Table source_table, list column_order, list null_precedence, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Sorts the table. @@ -432,7 +441,8 @@ cpdef Table sort( cdef vector[order] c_orders = column_order cdef vector[null_order] c_null_precedence = null_precedence - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -440,17 +450,17 @@ cpdef Table sort( source_table.view(), c_orders, c_null_precedence, - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef Table stable_sort( Table source_table, list column_order, list null_precedence, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Sorts the table preserving order of equal elements. @@ -475,7 +485,8 @@ cpdef Table stable_sort( cdef vector[order] c_orders = column_order cdef vector[null_order] c_null_precedence = null_precedence - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -483,17 +494,17 @@ cpdef Table stable_sort( source_table.view(), c_orders, c_null_precedence, - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef Column top_k( Column col, size_type k, order sort_order = order.DESCENDING, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -518,7 +529,8 @@ cpdef Column top_k( """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -526,17 +538,17 @@ cpdef Column top_k( col.view(), k, sort_order, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column top_k_order( Column col, size_type k, order sort_order = order.DESCENDING, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -564,7 +576,8 @@ cpdef Column top_k_order( """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -572,7 +585,7 @@ cpdef Column top_k_order( col.view(), k, sort_order, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/stream_compaction.pxd b/python/pylibcudf/pylibcudf/stream_compaction.pxd index 03b463f5f3a..6e904e11ce1 100644 --- a/python/pylibcudf/pylibcudf/stream_compaction.pxd +++ b/python/pylibcudf/pylibcudf/stream_compaction.pxd @@ -8,7 +8,6 @@ from pylibcudf.libcudf.types cimport ( size_type, ) from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream from .column cimport Column from .expressions cimport Expression @@ -19,7 +18,7 @@ cpdef Table drop_nulls( Table source_table, list keys, size_type keep_threshold, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -27,14 +26,14 @@ cpdef Table drop_nans( Table source_table, list keys, size_type keep_threshold, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) cpdef Table apply_boolean_mask( Table source_table, Column boolean_mask, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -43,7 +42,7 @@ cpdef Table unique( list keys, duplicate_keep_option keep, null_equality nulls_equal, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -53,7 +52,7 @@ cpdef Table distinct( duplicate_keep_option keep, null_equality nulls_equal, nan_equality nans_equal, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -62,7 +61,7 @@ cpdef Column distinct_indices( duplicate_keep_option keep, null_equality nulls_equal, nan_equality nans_equal, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -72,7 +71,7 @@ cpdef Table stable_distinct( duplicate_keep_option keep, null_equality nulls_equal, nan_equality nans_equal, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -80,6 +79,6 @@ cpdef Table filter( Table predicate_table, Expression predicate_expr, Table filter_table, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) diff --git a/python/pylibcudf/pylibcudf/stream_compaction.pyi b/python/pylibcudf/pylibcudf/stream_compaction.pyi index 49c44f82486..afdd692dde2 100644 --- a/python/pylibcudf/pylibcudf/stream_compaction.pyi +++ b/python/pylibcudf/pylibcudf/stream_compaction.pyi @@ -4,12 +4,12 @@ from enum import IntEnum from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.expressions import Expression from pylibcudf.table import Table from pylibcudf.types import NanEquality, NullEquality +from pylibcudf.utils import CudaStreamLike class DuplicateKeepOption(IntEnum): KEEP_ANY = ... @@ -21,20 +21,20 @@ def drop_nulls( source_table: Table, keys: list[int], keep_threshold: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def drop_nans( source_table: Table, keys: list[int], keep_threshold: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def apply_boolean_mask( source_table: Table, boolean_mask: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def unique( @@ -42,7 +42,7 @@ def unique( keys: list[int], keep: DuplicateKeepOption, nulls_equal: NullEquality, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def distinct( @@ -51,7 +51,7 @@ def distinct( keep: DuplicateKeepOption, nulls_equal: NullEquality, nans_equal: NanEquality, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def distinct_indices( @@ -59,7 +59,7 @@ def distinct_indices( keep: DuplicateKeepOption, nulls_equal: NullEquality, nans_equal: NanEquality, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def stable_distinct( @@ -68,13 +68,13 @@ def stable_distinct( keep: DuplicateKeepOption, nulls_equal: NullEquality, nans_equal: NanEquality, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def filter( predicate_table: Table, predicate_expr: Expression, filter_table: Table, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... diff --git a/python/pylibcudf/pylibcudf/stream_compaction.pyx b/python/pylibcudf/pylibcudf/stream_compaction.pyx index 4e676602cf8..b4751078acb 100644 --- a/python/pylibcudf/pylibcudf/stream_compaction.pyx +++ b/python/pylibcudf/pylibcudf/stream_compaction.pyx @@ -24,6 +24,7 @@ from .column cimport Column from .expressions cimport Expression from .table cimport Table from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "DuplicateKeepOption", @@ -41,7 +42,7 @@ cpdef Table drop_nulls( Table source_table, list keys, size_type keep_threshold, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Filters out rows from the input table based on the presence of nulls. @@ -65,21 +66,22 @@ cpdef Table drop_nulls( cdef unique_ptr[table] c_result cdef vector[size_type] c_keys = keys - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_stream_compaction.drop_nulls( - source_table.view(), c_keys, keep_threshold, stream.view(), mr.get_mr() + source_table.view(), c_keys, keep_threshold, _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef Table drop_nans( Table source_table, list keys, size_type keep_threshold, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Filters out rows from the input table based on the presence of NaNs. @@ -103,20 +105,21 @@ cpdef Table drop_nans( cdef unique_ptr[table] c_result cdef vector[size_type] c_keys = keys - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_stream_compaction.drop_nans( - source_table.view(), c_keys, keep_threshold, stream.view(), mr.get_mr() + source_table.view(), c_keys, keep_threshold, _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef Table apply_boolean_mask( Table source_table, Column boolean_mask, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Filters out rows from the input table based on a boolean mask. @@ -137,14 +140,15 @@ cpdef Table apply_boolean_mask( """ cdef unique_ptr[table] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_stream_compaction.apply_boolean_mask( - source_table.view(), boolean_mask.view(), stream.view(), mr.get_mr() + source_table.view(), boolean_mask.view(), _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef Table unique( @@ -152,7 +156,7 @@ cpdef Table unique( list keys, duplicate_keep_option keep, null_equality nulls_equal, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Filter duplicate consecutive rows from the input table. @@ -184,14 +188,15 @@ cpdef Table unique( cdef unique_ptr[table] c_result cdef vector[size_type] c_keys = keys - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_stream_compaction.unique( - input.view(), c_keys, keep, nulls_equal, stream.view(), mr.get_mr() + input.view(), c_keys, keep, nulls_equal, _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef Table distinct( @@ -200,7 +205,7 @@ cpdef Table distinct( duplicate_keep_option keep, null_equality nulls_equal, nan_equality nans_equal, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Get the distinct rows from the input table. @@ -229,15 +234,16 @@ cpdef Table distinct( cdef unique_ptr[table] c_result cdef vector[size_type] c_keys = keys - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_stream_compaction.distinct( - input.view(), c_keys, keep, nulls_equal, nans_equal, stream.view(), + input.view(), c_keys, keep, nulls_equal, nans_equal, _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef Column distinct_indices( @@ -245,7 +251,7 @@ cpdef Column distinct_indices( duplicate_keep_option keep, null_equality nulls_equal, nan_equality nans_equal, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Get the indices of the distinct rows from the input table. @@ -270,14 +276,15 @@ cpdef Column distinct_indices( """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_stream_compaction.distinct_indices( - input.view(), keep, nulls_equal, nans_equal, stream.view(), mr.get_mr() + input.view(), keep, nulls_equal, nans_equal, _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Table stable_distinct( @@ -286,7 +293,7 @@ cpdef Table stable_distinct( duplicate_keep_option keep, null_equality nulls_equal, nan_equality nans_equal, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Get the distinct rows from the input table, preserving input order. @@ -315,22 +322,23 @@ cpdef Table stable_distinct( cdef unique_ptr[table] c_result cdef vector[size_type] c_keys = keys - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_stream_compaction.stable_distinct( - input.view(), c_keys, keep, nulls_equal, nans_equal, stream.view(), + input.view(), c_keys, keep, nulls_equal, nans_equal, _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef Table filter( Table predicate_table, Expression predicate_expr, Table filter_table, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Filters a table using a predicate expression. @@ -353,7 +361,8 @@ cpdef Table filter( """ cdef unique_ptr[table] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -361,9 +370,9 @@ cpdef Table filter( predicate_table.view(), dereference(predicate_expr.c_obj.get()), filter_table.view(), - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) DuplicateKeepOption.__str__ = DuplicateKeepOption.__repr__ diff --git a/python/pylibcudf/pylibcudf/strings/attributes.pxd b/python/pylibcudf/pylibcudf/strings/attributes.pxd index 68b1ce9b5a0..64533b1ce3d 100644 --- a/python/pylibcudf/pylibcudf/strings/attributes.pxd +++ b/python/pylibcudf/pylibcudf/strings/attributes.pxd @@ -1,19 +1,18 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column count_characters( - Column source_strings, Stream stream=*, DeviceMemoryResource mr=* + Column source_strings, object stream = *, DeviceMemoryResource mr=* ) cpdef Column count_bytes( - Column source_strings, Stream stream=*, DeviceMemoryResource mr=* + Column source_strings, object stream = *, DeviceMemoryResource mr=* ) cpdef Column code_points( - Column source_strings, Stream stream=*, DeviceMemoryResource mr=* + Column source_strings, object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/strings/attributes.pyi b/python/pylibcudf/pylibcudf/strings/attributes.pyi index 06b76e669d3..2e28fb9f186 100644 --- a/python/pylibcudf/pylibcudf/strings/attributes.pyi +++ b/python/pylibcudf/pylibcudf/strings/attributes.pyi @@ -1,23 +1,23 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column +from pylibcudf.utils import CudaStreamLike def count_characters( source_strings: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def count_bytes( source_strings: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def code_points( source_strings: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/attributes.pyx b/python/pylibcudf/pylibcudf/strings/attributes.pyx index 2449d51122f..334270ea834 100644 --- a/python/pylibcudf/pylibcudf/strings/attributes.pyx +++ b/python/pylibcudf/pylibcudf/strings/attributes.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -9,11 +9,12 @@ from pylibcudf.libcudf.strings cimport attributes as cpp_attributes from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["code_points", "count_bytes", "count_characters"] cpdef Column count_characters( - Column source_strings, Stream stream=None, DeviceMemoryResource mr=None + Column source_strings, object stream=None, DeviceMemoryResource mr=None ): """ Returns a column containing character lengths of each string @@ -32,19 +33,20 @@ cpdef Column count_characters( New column with lengths for each string """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_attributes.count_characters( - source_strings.view(), stream.view(), mr.get_mr() + source_strings.view(), _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column count_bytes( - Column source_strings, Stream stream=None, DeviceMemoryResource mr=None + Column source_strings, object stream=None, DeviceMemoryResource mr=None ): """ Returns a column containing byte lengths of each string @@ -63,19 +65,20 @@ cpdef Column count_bytes( New column with the number of bytes for each string """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_attributes.count_bytes( - source_strings.view(), stream.view(), mr.get_mr() + source_strings.view(), _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column code_points( - Column source_strings, Stream stream=None, DeviceMemoryResource mr=None + Column source_strings, object stream=None, DeviceMemoryResource mr=None ): """ Creates a numeric column with code point values (integers) @@ -94,12 +97,13 @@ cpdef Column code_points( New column with code point integer values for each character """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_attributes.code_points( - source_strings.view(), stream.view(), mr.get_mr() + source_strings.view(), _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/capitalize.pxd b/python/pylibcudf/pylibcudf/strings/capitalize.pxd index ccbe15b3794..1a68c29e05c 100644 --- a/python/pylibcudf/pylibcudf/strings/capitalize.pxd +++ b/python/pylibcudf/pylibcudf/strings/capitalize.pxd @@ -1,20 +1,19 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.scalar cimport Scalar from pylibcudf.libcudf.strings.char_types cimport string_character_types from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column capitalize( - Column input, Scalar delimiters=*, Stream stream=*, DeviceMemoryResource mr=* + Column input, Scalar delimiters=*, object stream = *, DeviceMemoryResource mr=* ) cpdef Column title( Column input, string_character_types sequence_type=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) -cpdef Column is_title(Column input, Stream stream=*, DeviceMemoryResource mr=*) +cpdef Column is_title(Column input, object stream = *, DeviceMemoryResource mr=*) diff --git a/python/pylibcudf/pylibcudf/strings/capitalize.pyi b/python/pylibcudf/pylibcudf/strings/capitalize.pyi index 35554e6fff3..031d244bf25 100644 --- a/python/pylibcudf/pylibcudf/strings/capitalize.pyi +++ b/python/pylibcudf/pylibcudf/strings/capitalize.pyi @@ -1,27 +1,27 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar from pylibcudf.strings.char_types import StringCharacterTypes +from pylibcudf.utils import CudaStreamLike def capitalize( input: Column, delimiters: Scalar | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def title( input: Column, sequence_type: StringCharacterTypes = StringCharacterTypes.ALPHA, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def is_title( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/capitalize.pyx b/python/pylibcudf/pylibcudf/strings/capitalize.pyx index 11291bd1243..be8c52a59b5 100644 --- a/python/pylibcudf/pylibcudf/strings/capitalize.pyx +++ b/python/pylibcudf/pylibcudf/strings/capitalize.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -17,13 +17,14 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream from cython.operator import dereference +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["capitalize", "is_title", "title"] cpdef Column capitalize( Column input, Scalar delimiters=None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, # TODO: default scalar values # https://github.com/rapidsai/cudf/issues/15505 @@ -45,12 +46,13 @@ cpdef Column capitalize( Column of strings capitalized from the input column """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if delimiters is None: delimiters = Scalar.from_libcudf( - cpp_make_string_scalar("".encode(), stream.view(), mr.get_mr()) + cpp_make_string_scalar("".encode(), _stream.view().value(), mr.get_mr()) ) cdef const string_scalar* cpp_delimiters = ( @@ -61,17 +63,17 @@ cpdef Column capitalize( c_result = cpp_capitalize.capitalize( input.view(), dereference(cpp_delimiters), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column title( Column input, string_character_types sequence_type=string_character_types.ALPHA, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Modifies first character of each word to upper-case and lower-cases @@ -92,17 +94,18 @@ cpdef Column title( Column of titled strings """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_capitalize.title( - input.view(), sequence_type, stream.view(), mr.get_mr() + input.view(), sequence_type, _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) -cpdef Column is_title(Column input, Stream stream=None, DeviceMemoryResource mr=None): +cpdef Column is_title(Column input, object stream=None, DeviceMemoryResource mr=None): """Checks if the strings in the input column are title formatted. For details, see :cpp:func:`is_title`. @@ -118,9 +121,10 @@ cpdef Column is_title(Column input, Stream stream=None, DeviceMemoryResource mr= Column of type BOOL8 """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_capitalize.is_title(input.view(), stream.view(), mr.get_mr()) + c_result = cpp_capitalize.is_title(input.view(), _cs, mr.get_mr()) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/case.pxd b/python/pylibcudf/pylibcudf/strings/case.pxd index 8a959fb61d5..fea9f68e95e 100644 --- a/python/pylibcudf/pylibcudf/strings/case.pxd +++ b/python/pylibcudf/pylibcudf/strings/case.pxd @@ -1,11 +1,10 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream -cpdef Column to_lower(Column input, Stream stream=*, DeviceMemoryResource mr=*) -cpdef Column to_upper(Column input, Stream stream=*, DeviceMemoryResource mr=*) -cpdef Column swapcase(Column input, Stream stream=*, DeviceMemoryResource mr=*) +cpdef Column to_lower(Column input, object stream = *, DeviceMemoryResource mr=*) +cpdef Column to_upper(Column input, object stream = *, DeviceMemoryResource mr=*) +cpdef Column swapcase(Column input, object stream = *, DeviceMemoryResource mr=*) diff --git a/python/pylibcudf/pylibcudf/strings/case.pyi b/python/pylibcudf/pylibcudf/strings/case.pyi index ecdb614fcd7..1337e7df5a9 100644 --- a/python/pylibcudf/pylibcudf/strings/case.pyi +++ b/python/pylibcudf/pylibcudf/strings/case.pyi @@ -1,23 +1,23 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column +from pylibcudf.utils import CudaStreamLike def to_lower( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def to_upper( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def swapcase( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/case.pyx b/python/pylibcudf/pylibcudf/strings/case.pyx index 5e7d20f01f8..ec6539f42e1 100644 --- a/python/pylibcudf/pylibcudf/strings/case.pyx +++ b/python/pylibcudf/pylibcudf/strings/case.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -9,10 +9,11 @@ from pylibcudf.libcudf.strings cimport case as cpp_case from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["swapcase", "to_lower", "to_upper"] -cpdef Column to_lower(Column input, Stream stream=None, DeviceMemoryResource mr=None): +cpdef Column to_lower(Column input, object stream=None, DeviceMemoryResource mr=None): """Returns a column of lowercased strings. For details, see :cpp:func:`to_lower`. @@ -32,14 +33,15 @@ cpdef Column to_lower(Column input, Stream stream=None, DeviceMemoryResource mr= Column of strings lowercased from the input column """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_case.to_lower(input.view(), stream.view(), mr.get_mr()) + c_result = cpp_case.to_lower(input.view(), _cs, mr.get_mr()) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) -cpdef Column to_upper(Column input, Stream stream=None, DeviceMemoryResource mr=None): +cpdef Column to_upper(Column input, object stream=None, DeviceMemoryResource mr=None): """Returns a column of uppercased strings. For details, see :cpp:func:`to_upper`. @@ -59,14 +61,15 @@ cpdef Column to_upper(Column input, Stream stream=None, DeviceMemoryResource mr= Column of strings uppercased from the input column """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_case.to_upper(input.view(), stream.view(), mr.get_mr()) + c_result = cpp_case.to_upper(input.view(), _cs, mr.get_mr()) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) -cpdef Column swapcase(Column input, Stream stream=None, DeviceMemoryResource mr=None): +cpdef Column swapcase(Column input, object stream=None, DeviceMemoryResource mr=None): """Returns a column of strings where the lowercase characters are converted to uppercase and the uppercase characters are converted to lowercase. @@ -88,9 +91,10 @@ cpdef Column swapcase(Column input, Stream stream=None, DeviceMemoryResource mr= Column of strings """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_case.swapcase(input.view(), stream.view(), mr.get_mr()) + c_result = cpp_case.swapcase(input.view(), _cs, mr.get_mr()) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/char_types.pxd b/python/pylibcudf/pylibcudf/strings/char_types.pxd index 009886f3e9f..59c045dba15 100644 --- a/python/pylibcudf/pylibcudf/strings/char_types.pxd +++ b/python/pylibcudf/pylibcudf/strings/char_types.pxd @@ -1,18 +1,17 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.libcudf.strings.char_types cimport string_character_types from pylibcudf.scalar cimport Scalar from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column all_characters_of_type( Column source_strings, string_character_types types, string_character_types verify_types, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) @@ -21,6 +20,6 @@ cpdef Column filter_characters_of_type( string_character_types types_to_remove, Scalar replacement, string_character_types types_to_keep, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/strings/char_types.pyi b/python/pylibcudf/pylibcudf/strings/char_types.pyi index 12749d79f6d..1740a67eb00 100644 --- a/python/pylibcudf/pylibcudf/strings/char_types.pyi +++ b/python/pylibcudf/pylibcudf/strings/char_types.pyi @@ -1,13 +1,13 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from enum import IntEnum from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar +from pylibcudf.utils import CudaStreamLike class StringCharacterTypes(IntEnum): DECIMAL = ... @@ -25,7 +25,7 @@ def all_characters_of_type( source_strings: Column, types: StringCharacterTypes, verify_types: StringCharacterTypes, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def filter_characters_of_type( @@ -33,6 +33,6 @@ def filter_characters_of_type( types_to_remove: StringCharacterTypes, replacement: Scalar, types_to_keep: StringCharacterTypes, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/char_types.pyx b/python/pylibcudf/pylibcudf/strings/char_types.pyx index 5cb5025798e..2567ab8ee4b 100644 --- a/python/pylibcudf/pylibcudf/strings/char_types.pyx +++ b/python/pylibcudf/pylibcudf/strings/char_types.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -14,6 +14,7 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream from cython.operator import dereference +from cuda.bindings.cyruntime cimport cudaStream_t from pylibcudf.libcudf.strings.char_types import \ string_character_types as StringCharacterTypes # no-cython-lint @@ -27,7 +28,7 @@ cpdef Column all_characters_of_type( Column source_strings, string_character_types types, string_character_types verify_types, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -50,7 +51,8 @@ cpdef Column all_characters_of_type( New column of boolean results for each string """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -58,18 +60,18 @@ cpdef Column all_characters_of_type( source_strings.view(), types, verify_types, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column filter_characters_of_type( Column source_strings, string_character_types types_to_remove, Scalar replacement, string_character_types types_to_keep, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -99,7 +101,8 @@ cpdef Column filter_characters_of_type( replacement.c_obj.get() ) cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -108,10 +111,10 @@ cpdef Column filter_characters_of_type( types_to_remove, dereference(c_replacement), types_to_keep, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) StringCharacterTypes.__str__ = StringCharacterTypes.__repr__ diff --git a/python/pylibcudf/pylibcudf/strings/combine.pxd b/python/pylibcudf/pylibcudf/strings/combine.pxd index b889169c7c7..32a58abdc23 100644 --- a/python/pylibcudf/pylibcudf/strings/combine.pxd +++ b/python/pylibcudf/pylibcudf/strings/combine.pxd @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column @@ -9,7 +9,6 @@ from pylibcudf.libcudf.strings.combine cimport ( from pylibcudf.scalar cimport Scalar from pylibcudf.table cimport Table from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream ctypedef fused ColumnOrScalar: Column @@ -21,7 +20,7 @@ cpdef Column concatenate( Scalar narep=*, Scalar col_narep=*, separator_on_nulls separate_nulls=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -29,7 +28,7 @@ cpdef Column join_strings( Column input, Scalar separator, Scalar narep, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -40,6 +39,6 @@ cpdef Column join_list_elements( Scalar string_narep, separator_on_nulls separate_nulls, output_if_empty_list empty_list_policy, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) diff --git a/python/pylibcudf/pylibcudf/strings/combine.pyi b/python/pylibcudf/pylibcudf/strings/combine.pyi index fa568046fa8..3186709996f 100644 --- a/python/pylibcudf/pylibcudf/strings/combine.pyi +++ b/python/pylibcudf/pylibcudf/strings/combine.pyi @@ -1,14 +1,14 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from enum import IntEnum from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar from pylibcudf.table import Table +from pylibcudf.utils import CudaStreamLike class SeparatorOnNulls(IntEnum): YES = ... @@ -24,14 +24,14 @@ def concatenate( narep: Scalar | None = None, col_narep: Scalar | None = None, separate_nulls: SeparatorOnNulls = SeparatorOnNulls.YES, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def join_strings( input: Column, separator: Scalar, narep: Scalar, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def join_list_elements( @@ -41,6 +41,6 @@ def join_list_elements( string_narep: Scalar, separate_nulls: SeparatorOnNulls, empty_list_policy: OutputIfEmptyList, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/combine.pyx b/python/pylibcudf/pylibcudf/strings/combine.pyx index e570a18c585..82903002907 100644 --- a/python/pylibcudf/pylibcudf/strings/combine.pyx +++ b/python/pylibcudf/pylibcudf/strings/combine.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr from libcpp.utility cimport move @@ -16,6 +16,7 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream from cython.operator import dereference +from cuda.bindings.cyruntime cimport cudaStream_t from pylibcudf.libcudf.strings.combine import \ output_if_empty_list as OutputIfEmptyList # no-cython-lint from pylibcudf.libcudf.strings.combine import \ @@ -35,7 +36,7 @@ cpdef Column concatenate( Scalar narep=None, Scalar col_narep=None, separator_on_nulls separate_nulls=separator_on_nulls.YES, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -68,12 +69,13 @@ cpdef Column concatenate( cdef unique_ptr[column] c_result cdef const string_scalar* c_col_narep cdef const string_scalar* c_separator - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if narep is None: narep = Scalar.from_libcudf( - cpp_make_string_scalar("".encode(), stream.view(), mr.get_mr()) + cpp_make_string_scalar("".encode(), _stream.view().value(), mr.get_mr()) ) cdef const string_scalar* c_narep = ( narep.c_obj.get() @@ -82,7 +84,7 @@ cpdef Column concatenate( if ColumnOrScalar is Column: if col_narep is None: col_narep = Scalar.from_libcudf( - cpp_make_string_scalar("".encode(), stream.view(), mr.get_mr()) + cpp_make_string_scalar("".encode(), _stream.view().value(), mr.get_mr()) ) c_col_narep = ( col_narep.c_obj.get() @@ -95,7 +97,7 @@ cpdef Column concatenate( dereference(c_narep), dereference(c_col_narep), separate_nulls, - stream.view(), + _cs, mr.get_mr() ) ) @@ -112,20 +114,20 @@ cpdef Column concatenate( dereference(c_separator), dereference(c_narep), separate_nulls, - stream.view(), + _cs, mr.get_mr() ) ) else: raise ValueError("separator must be a Column or a Scalar") - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column join_strings( Column input, Scalar separator, Scalar narep, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -149,7 +151,8 @@ cpdef Column join_strings( New column containing one string """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) cdef const string_scalar* c_separator = ( separator.c_obj.get() @@ -163,12 +166,12 @@ cpdef Column join_strings( input.view(), dereference(c_separator), dereference(c_narep), - stream.view(), + _cs, mr.get_mr() ) ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column join_list_elements( @@ -178,7 +181,7 @@ cpdef Column join_list_elements( Scalar string_narep, separator_on_nulls separate_nulls, output_if_empty_list empty_list_policy, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -217,7 +220,8 @@ cpdef Column join_list_elements( New strings column with concatenated results """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) cdef const string_scalar* c_separator_narep = ( separator_narep.c_obj.get() @@ -237,7 +241,7 @@ cpdef Column join_list_elements( dereference(c_string_narep), separate_nulls, empty_list_policy, - stream.view(), + _cs, mr.get_mr() ) ) @@ -251,13 +255,13 @@ cpdef Column join_list_elements( dereference(c_separator_narep), separate_nulls, empty_list_policy, - stream.view(), + _cs, mr.get_mr() ) ) else: raise ValueError("separator must be a Column or a Scalar") - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) OutputIfEmptyList.__str__ = OutputIfEmptyList.__repr__ SeparatorOnNulls.__str__ = SeparatorOnNulls.__repr__ diff --git a/python/pylibcudf/pylibcudf/strings/contains.pxd b/python/pylibcudf/pylibcudf/strings/contains.pxd index b3b0f06efb5..585f2fac1ff 100644 --- a/python/pylibcudf/pylibcudf/strings/contains.pxd +++ b/python/pylibcudf/pylibcudf/strings/contains.pxd @@ -1,28 +1,27 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.strings.regex_program cimport RegexProgram from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column contains_re( - Column input, RegexProgram prog, Stream stream=*, DeviceMemoryResource mr=* + Column input, RegexProgram prog, object stream = *, DeviceMemoryResource mr=* ) cpdef Column count_re( - Column input, RegexProgram prog, Stream stream=*, DeviceMemoryResource mr=* + Column input, RegexProgram prog, object stream = *, DeviceMemoryResource mr=* ) cpdef Column matches_re( - Column input, RegexProgram prog, Stream stream=*, DeviceMemoryResource mr=* + Column input, RegexProgram prog, object stream = *, DeviceMemoryResource mr=* ) cpdef Column like( Column input, str pattern, str escape_character=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) diff --git a/python/pylibcudf/pylibcudf/strings/contains.pyi b/python/pylibcudf/pylibcudf/strings/contains.pyi index 3685cf5345a..b751ef0b24c 100644 --- a/python/pylibcudf/pylibcudf/strings/contains.pyi +++ b/python/pylibcudf/pylibcudf/strings/contains.pyi @@ -1,34 +1,34 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.strings.regex_program import RegexProgram +from pylibcudf.utils import CudaStreamLike def contains_re( input: Column, prog: RegexProgram, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def count_re( input: Column, prog: RegexProgram, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def matches_re( input: Column, prog: RegexProgram, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def like( input: Column, pattern: str, escape_character: str | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/contains.pyx b/python/pylibcudf/pylibcudf/strings/contains.pyx index 8fe74228854..495d1637d8a 100644 --- a/python/pylibcudf/pylibcudf/strings/contains.pyx +++ b/python/pylibcudf/pylibcudf/strings/contains.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr from libcpp.utility cimport move @@ -11,13 +11,14 @@ from pylibcudf.strings.regex_program cimport RegexProgram from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["contains_re", "count_re", "like", "matches_re"] cpdef Column contains_re( Column input, RegexProgram prog, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Returns a boolean column identifying rows which match the given @@ -39,24 +40,27 @@ cpdef Column contains_re( """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() + if _stream is None: + _stream = _get_stream(None) mr = _get_memory_resource(mr) with nogil: result = cpp_contains.contains_re( input.view(), prog.c_obj.get()[0], - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column count_re( Column input, RegexProgram prog, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Returns the number of times the given regex_program's pattern @@ -78,24 +82,25 @@ cpdef Column count_re( """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: result = cpp_contains.count_re( input.view(), prog.c_obj.get()[0], - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column matches_re( Column input, RegexProgram prog, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Returns a boolean column identifying rows which @@ -118,25 +123,26 @@ cpdef Column matches_re( """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: result = cpp_contains.matches_re( input.view(), prog.c_obj.get()[0], - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column like( Column input, str pattern, str escape_character=None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -161,7 +167,8 @@ cpdef Column like( New column of boolean results for each string """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if escape_character is None: @@ -175,9 +182,9 @@ cpdef Column like( input.view(), c_pattern, c_escape_character, - stream.view(), + _cs, mr.get_mr() ) - stream.synchronize() + _stream.synchronize() - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_booleans.pxd b/python/pylibcudf/pylibcudf/strings/convert/convert_booleans.pxd index cc1206cf29b..0929544287f 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_booleans.pxd +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_booleans.pxd @@ -1,20 +1,19 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.scalar cimport Scalar from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column to_booleans( - Column input, Scalar true_string, Stream stream=*, DeviceMemoryResource mr=* + Column input, Scalar true_string, object stream = *, DeviceMemoryResource mr=* ) cpdef Column from_booleans( Column booleans, Scalar true_string, Scalar false_string, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_booleans.pyi b/python/pylibcudf/pylibcudf/strings/convert/convert_booleans.pyi index 608b47bad8c..10c7b96bfc0 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_booleans.pyi +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_booleans.pyi @@ -1,22 +1,22 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar +from pylibcudf.utils import CudaStreamLike def to_booleans( input: Column, true_string: Scalar, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def from_booleans( booleans: Column, true_string: Scalar, false_string: Scalar, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_booleans.pyx b/python/pylibcudf/pylibcudf/strings/convert/convert_booleans.pyx index 6f7965f8a3b..e8f963cf0f3 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_booleans.pyx +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_booleans.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -15,11 +15,12 @@ from pylibcudf.utils cimport _get_stream, _get_memory_resource from cython.operator import dereference from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["from_booleans", "to_booleans"] cpdef Column to_booleans( - Column input, Scalar true_string, Stream stream=None, DeviceMemoryResource mr=None + Column input, Scalar true_string, object stream=None, DeviceMemoryResource mr=None ): """ Returns a new bool column by parsing boolean values from the strings @@ -47,24 +48,25 @@ cpdef Column to_booleans( cdef const string_scalar* c_true_string = ( true_string.c_obj.get() ) - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_convert_booleans.to_booleans( input.view(), dereference(c_true_string), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column from_booleans( Column booleans, Scalar true_string, Scalar false_string, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -99,7 +101,8 @@ cpdef Column from_booleans( cdef const string_scalar* c_false_string = ( false_string.c_obj.get() ) - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -107,8 +110,8 @@ cpdef Column from_booleans( booleans.view(), dereference(c_true_string), dereference(c_false_string), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_datetime.pxd b/python/pylibcudf/pylibcudf/strings/convert/convert_datetime.pxd index 407eb06ce6a..d0a5d2fc829 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_datetime.pxd +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_datetime.pxd @@ -1,18 +1,17 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.string cimport string from pylibcudf.column cimport Column from pylibcudf.types cimport DataType from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column to_timestamps( Column input, DataType timestamp_type, str format, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) @@ -20,13 +19,13 @@ cpdef Column from_timestamps( Column timestamps, str format, Column input_strings_names, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) cpdef Column is_timestamp( Column input, str format, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_datetime.pyi b/python/pylibcudf/pylibcudf/strings/convert/convert_datetime.pyi index 5fdc863705d..99f067ecb04 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_datetime.pyi +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_datetime.pyi @@ -1,29 +1,29 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.types import DataType +from pylibcudf.utils import CudaStreamLike def to_timestamps( input: Column, timestamp_type: DataType, format: str, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def from_timestamps( timestamps: Column, format: str, input_strings_names: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def is_timestamp( input: Column, format: str, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_datetime.pyx b/python/pylibcudf/pylibcudf/strings/convert/convert_datetime.pyx index 07b35de7c54..633445a7383 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_datetime.pyx +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_datetime.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -14,6 +14,7 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream from pylibcudf.types import DataType +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["from_timestamps", "is_timestamp", "to_timestamps"] @@ -21,7 +22,7 @@ cpdef Column to_timestamps( Column input, DataType timestamp_type, str format, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -51,24 +52,25 @@ cpdef Column to_timestamps( """ cdef unique_ptr[column] c_result cdef string c_format = format.encode() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_convert_datetime.to_timestamps( input.view(), timestamp_type.c_obj, c_format, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column from_timestamps( Column timestamps, str format, Column input_strings_names, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -98,23 +100,24 @@ cpdef Column from_timestamps( """ cdef unique_ptr[column] c_result cdef string c_format = format.encode() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_convert_datetime.from_timestamps( timestamps.view(), c_format, input_strings_names.view(), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column is_timestamp( Column input, str format, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -141,14 +144,15 @@ cpdef Column is_timestamp( """ cdef unique_ptr[column] c_result cdef string c_format = format.encode() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_convert_datetime.is_timestamp( input.view(), c_format, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_durations.pxd b/python/pylibcudf/pylibcudf/strings/convert/convert_durations.pxd index 62b372d0af4..a912d939a83 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_durations.pxd +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_durations.pxd @@ -1,24 +1,23 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.string cimport string from pylibcudf.column cimport Column from pylibcudf.types cimport DataType from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column to_durations( Column input, DataType duration_type, str format, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) cpdef Column from_durations( Column durations, str format=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_durations.pyi b/python/pylibcudf/pylibcudf/strings/convert/convert_durations.pyi index 95ba392ec94..ac9fd9825dc 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_durations.pyi +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_durations.pyi @@ -1,22 +1,22 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.types import DataType +from pylibcudf.utils import CudaStreamLike def to_durations( input: Column, duration_type: DataType, format: str, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def from_durations( durations: Column, format: str | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_durations.pyx b/python/pylibcudf/pylibcudf/strings/convert/convert_durations.pyx index 9bf8eb96009..548df7398b4 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_durations.pyx +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_durations.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -14,6 +14,7 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream from pylibcudf.types import DataType +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["from_durations", "to_durations"] @@ -21,7 +22,7 @@ cpdef Column to_durations( Column input, DataType duration_type, str format, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """ @@ -51,7 +52,8 @@ cpdef Column to_durations( """ cdef unique_ptr[column] c_result cdef string c_format = format.encode() - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -59,16 +61,16 @@ cpdef Column to_durations( input.view(), duration_type.c_obj, c_format, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column from_durations( Column durations, str format=None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ): """ @@ -95,7 +97,8 @@ cpdef Column from_durations( New strings column with formatted durations. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if format is None: @@ -106,8 +109,8 @@ cpdef Column from_durations( c_result = cpp_convert_durations.from_durations( durations.view(), c_format, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_fixed_point.pxd b/python/pylibcudf/pylibcudf/strings/convert/convert_fixed_point.pxd index 046556db181..439f8884008 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_fixed_point.pxd +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_fixed_point.pxd @@ -1,26 +1,25 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.types cimport DataType from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column to_fixed_point( Column input, DataType output_type, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) cpdef Column from_fixed_point( - Column input, Stream stream=*, DeviceMemoryResource mr=* + Column input, object stream = *, DeviceMemoryResource mr=* ) cpdef Column is_fixed_point( Column input, DataType decimal_type=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_fixed_point.pyi b/python/pylibcudf/pylibcudf/strings/convert/convert_fixed_point.pyi index 7269f970069..a9d4a0eac98 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_fixed_point.pyi +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_fixed_point.pyi @@ -1,26 +1,26 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.types import DataType +from pylibcudf.utils import CudaStreamLike def to_fixed_point( input: Column, output_type: DataType, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def from_fixed_point( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def is_fixed_point( input: Column, decimal_type: DataType | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_fixed_point.pyx b/python/pylibcudf/pylibcudf/strings/convert/convert_fixed_point.pyx index 13020a5ee73..059373790c5 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_fixed_point.pyx +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_fixed_point.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -12,12 +12,13 @@ from pylibcudf.types cimport DataType, type_id from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["from_fixed_point", "is_fixed_point", "to_fixed_point"] cpdef Column to_fixed_point( - Column input, DataType output_type, Stream stream=None, DeviceMemoryResource mr=None + Column input, DataType output_type, object stream=None, DeviceMemoryResource mr=None ): """ Returns a new fixed-point column parsing decimal values from the @@ -42,21 +43,22 @@ cpdef Column to_fixed_point( New column of output_type. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_fixed_point.to_fixed_point( input.view(), output_type.c_obj, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column from_fixed_point( - Column input, Stream stream=None, DeviceMemoryResource mr=None + Column input, object stream=None, DeviceMemoryResource mr=None ): """ Returns a new strings column converting the fixed-point values @@ -78,20 +80,21 @@ cpdef Column from_fixed_point( New strings column. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_fixed_point.from_fixed_point( - input.view(), stream.view(), mr.get_mr() + input.view(), _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column is_fixed_point( Column input, DataType decimal_type=None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -118,7 +121,8 @@ cpdef Column is_fixed_point( New column of boolean results for each string. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if decimal_type is None: @@ -128,8 +132,8 @@ cpdef Column is_fixed_point( c_result = cpp_fixed_point.is_fixed_point( input.view(), decimal_type.c_obj, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_floats.pxd b/python/pylibcudf/pylibcudf/strings/convert/convert_floats.pxd index a2b98fa0b74..0d394fa1fe7 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_floats.pxd +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_floats.pxd @@ -1,16 +1,15 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.types cimport DataType from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column to_floats( - Column strings, DataType output_type, Stream stream=*, DeviceMemoryResource mr=* + Column strings, DataType output_type, object stream = *, DeviceMemoryResource mr=* ) -cpdef Column from_floats(Column floats, Stream stream=*, DeviceMemoryResource mr=*) +cpdef Column from_floats(Column floats, object stream = *, DeviceMemoryResource mr=*) -cpdef Column is_float(Column input, Stream stream=*, DeviceMemoryResource mr=*) +cpdef Column is_float(Column input, object stream = *, DeviceMemoryResource mr=*) diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_floats.pyi b/python/pylibcudf/pylibcudf/strings/convert/convert_floats.pyi index b5c8d7e7497..b334dfef9c7 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_floats.pyi +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_floats.pyi @@ -1,25 +1,25 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.types import DataType +from pylibcudf.utils import CudaStreamLike def to_floats( strings: Column, output_type: DataType, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def from_floats( floats: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def is_float( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_floats.pyx b/python/pylibcudf/pylibcudf/strings/convert/convert_floats.pyx index 59ac17a3e1c..d4901ce7be6 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_floats.pyx +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_floats.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -12,13 +12,14 @@ from pylibcudf.types cimport DataType from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["from_floats", "is_float", "to_floats"] cpdef Column to_floats( Column strings, DataType output_type, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -44,22 +45,23 @@ cpdef Column to_floats( New column with floats converted from strings. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_convert_floats.to_floats( strings.view(), output_type.c_obj, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column from_floats( - Column floats, Stream stream=None, DeviceMemoryResource mr=None + Column floats, object stream=None, DeviceMemoryResource mr=None ): """ Returns a new strings column converting the float values from the @@ -81,18 +83,19 @@ cpdef Column from_floats( New strings column with floats as strings. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_convert_floats.from_floats( - floats.view(), stream.view(), mr.get_mr() + floats.view(), _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) -cpdef Column is_float(Column input, Stream stream=None, DeviceMemoryResource mr=None): +cpdef Column is_float(Column input, object stream=None, DeviceMemoryResource mr=None): """ Returns a boolean column identifying strings in which all characters are valid for conversion to floats. @@ -113,10 +116,13 @@ cpdef Column is_float(Column input, Stream stream=None, DeviceMemoryResource mr= New column of boolean results for each string. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_convert_floats.is_float(input.view(), stream.view(), mr.get_mr()) + c_result = cpp_convert_floats.is_float( + input.view(), _cs, mr.get_mr() + ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_integers.pxd b/python/pylibcudf/pylibcudf/strings/convert/convert_integers.pxd index 376081e9b20..059e8c31f19 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_integers.pxd +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_integers.pxd @@ -1,32 +1,31 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.types cimport DataType from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column to_integers( - Column input, DataType output_type, Stream stream=*, DeviceMemoryResource mr=* + Column input, DataType output_type, object stream = *, DeviceMemoryResource mr=* ) cpdef Column from_integers( - Column integers, Stream stream=*, DeviceMemoryResource mr=* + Column integers, object stream = *, DeviceMemoryResource mr=* ) cpdef Column is_integer( - Column input, DataType int_type=*, Stream stream=*, DeviceMemoryResource mr=* + Column input, DataType int_type=*, object stream = *, DeviceMemoryResource mr=* ) cpdef Column hex_to_integers( - Column input, DataType output_type, Stream stream=*, DeviceMemoryResource mr=* + Column input, DataType output_type, object stream = *, DeviceMemoryResource mr=* ) cpdef Column is_hex( - Column input, Stream stream=*, DeviceMemoryResource mr=* + Column input, object stream = *, DeviceMemoryResource mr=* ) cpdef Column integers_to_hex( - Column input, Stream stream=*, DeviceMemoryResource mr=* + Column input, object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_integers.pyi b/python/pylibcudf/pylibcudf/strings/convert/convert_integers.pyi index 4625ee5e883..88a66350466 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_integers.pyi +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_integers.pyi @@ -1,42 +1,42 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.types import DataType +from pylibcudf.utils import CudaStreamLike def to_integers( input: Column, output_type: DataType, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def from_integers( integers: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def is_integer( input: Column, int_type: DataType | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def hex_to_integers( input: Column, output_type: DataType, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def is_hex( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def integers_to_hex( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_integers.pyx b/python/pylibcudf/pylibcudf/strings/convert/convert_integers.pyx index c5945e5e1e5..b717ddbbcda 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_integers.pyx +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_integers.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -12,6 +12,7 @@ from pylibcudf.types cimport DataType from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "from_integers", @@ -23,7 +24,7 @@ __all__ = [ ] cpdef Column to_integers( - Column input, DataType output_type, Stream stream=None, DeviceMemoryResource mr=None + Column input, DataType output_type, object stream=None, DeviceMemoryResource mr=None ): """ Returns a new integer numeric column parsing integer values from the @@ -48,7 +49,8 @@ cpdef Column to_integers( New column with integers converted from strings. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -56,16 +58,16 @@ cpdef Column to_integers( cpp_convert_integers.to_integers( input.view(), output_type.c_obj, - stream.view(), + _cs, mr.get_mr() ) ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column from_integers( - Column integers, Stream stream=None, DeviceMemoryResource mr=None + Column integers, object stream=None, DeviceMemoryResource mr=None ): """ Returns a new strings column converting the integer values from the @@ -87,25 +89,26 @@ cpdef Column from_integers( New strings column with integers as strings. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = move( cpp_convert_integers.from_integers( integers.view(), - stream.view(), + _cs, mr.get_mr() ) ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column is_integer( Column input, DataType int_type=None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -133,7 +136,8 @@ cpdef Column is_integer( New column of boolean results for each string. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if int_type is None: @@ -141,7 +145,7 @@ cpdef Column is_integer( c_result = move( cpp_convert_integers.is_integer( input.view(), - stream.view(), + _cs, mr.get_mr() ) ) @@ -151,16 +155,16 @@ cpdef Column is_integer( cpp_convert_integers.is_integer( input.view(), int_type.c_obj, - stream.view(), + _cs, mr.get_mr() ) ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column hex_to_integers( - Column input, DataType output_type, Stream stream=None, DeviceMemoryResource mr=None + Column input, DataType output_type, object stream=None, DeviceMemoryResource mr=None ): """ Returns a new integer numeric column parsing hexadecimal values @@ -185,7 +189,8 @@ cpdef Column hex_to_integers( New column with integers converted from strings. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -193,15 +198,15 @@ cpdef Column hex_to_integers( cpp_convert_integers.hex_to_integers( input.view(), output_type.c_obj, - stream.view(), + _cs, mr.get_mr() ) ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) -cpdef Column is_hex(Column input, Stream stream=None, DeviceMemoryResource mr=None): +cpdef Column is_hex(Column input, object stream=None, DeviceMemoryResource mr=None): """ Returns a boolean column identifying strings in which all characters are valid for conversion to integers from hex. @@ -222,23 +227,24 @@ cpdef Column is_hex(Column input, Stream stream=None, DeviceMemoryResource mr=No New column of boolean results for each string. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = move( cpp_convert_integers.is_hex( input.view(), - stream.view(), + _cs, mr.get_mr() ) ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column integers_to_hex( - Column input, Stream stream=None, DeviceMemoryResource mr=None + Column input, object stream=None, DeviceMemoryResource mr=None ): """ Returns a new strings column converting integer columns to hexadecimal @@ -260,16 +266,17 @@ cpdef Column integers_to_hex( New strings column with hexadecimal characters. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = move( cpp_convert_integers.integers_to_hex( input.view(), - stream.view(), + _cs, mr.get_mr() ) ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_ipv4.pxd b/python/pylibcudf/pylibcudf/strings/convert/convert_ipv4.pxd index 53a3927af41..04df2862c31 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_ipv4.pxd +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_ipv4.pxd @@ -1,19 +1,18 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column ipv4_to_integers( - Column input, Stream stream=*, DeviceMemoryResource mr=* + Column input, object stream = *, DeviceMemoryResource mr=* ) cpdef Column integers_to_ipv4( - Column integers, Stream stream=*, DeviceMemoryResource mr=* + Column integers, object stream = *, DeviceMemoryResource mr=* ) cpdef Column is_ipv4( - Column input, Stream stream=*, DeviceMemoryResource mr=* + Column input, object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_ipv4.pyi b/python/pylibcudf/pylibcudf/strings/convert/convert_ipv4.pyi index 86a969a4021..16e4d8d990a 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_ipv4.pyi +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_ipv4.pyi @@ -1,23 +1,23 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column +from pylibcudf.utils import CudaStreamLike def ipv4_to_integers( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def integers_to_ipv4( integers: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def is_ipv4( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_ipv4.pyx b/python/pylibcudf/pylibcudf/strings/convert/convert_ipv4.pyx index 72021e85a9d..45b98190aa7 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_ipv4.pyx +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_ipv4.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -9,11 +9,12 @@ from pylibcudf.libcudf.strings.convert cimport convert_ipv4 as cpp_convert_ipv4 from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["integers_to_ipv4", "ipv4_to_integers", "is_ipv4"] cpdef Column ipv4_to_integers( - Column input, Stream stream=None, DeviceMemoryResource mr=None + Column input, object stream=None, DeviceMemoryResource mr=None ): """ Converts IPv4 addresses into integers. @@ -34,19 +35,20 @@ cpdef Column ipv4_to_integers( New uint32 column converted from strings. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_convert_ipv4.ipv4_to_integers( - input.view(), stream.view(), mr.get_mr() + input.view(), _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column integers_to_ipv4( - Column integers, Stream stream=None, DeviceMemoryResource mr=None + Column integers, object stream=None, DeviceMemoryResource mr=None ): """ Converts integers into IPv4 addresses as strings. @@ -67,18 +69,19 @@ cpdef Column integers_to_ipv4( New strings column. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_convert_ipv4.integers_to_ipv4( - integers.view(), stream.view(), mr.get_mr() + integers.view(), _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) -cpdef Column is_ipv4(Column input, Stream stream=None, DeviceMemoryResource mr=None): +cpdef Column is_ipv4(Column input, object stream=None, DeviceMemoryResource mr=None): """ Returns a boolean column identifying strings in which all characters are valid for conversion to integers from IPv4 format. @@ -99,10 +102,11 @@ cpdef Column is_ipv4(Column input, Stream stream=None, DeviceMemoryResource mr=N New column of boolean results for each string. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_convert_ipv4.is_ipv4(input.view(), stream.view(), mr.get_mr()) + c_result = cpp_convert_ipv4.is_ipv4(input.view(), _cs, mr.get_mr()) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_lists.pxd b/python/pylibcudf/pylibcudf/strings/convert/convert_lists.pxd index a2dcc15dacd..c25cf9d7146 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_lists.pxd +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_lists.pxd @@ -1,16 +1,15 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.scalar cimport Scalar from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column format_list_column( Column input, Scalar na_rep=*, Column separators=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_lists.pyi b/python/pylibcudf/pylibcudf/strings/convert/convert_lists.pyi index cf301dd9a1b..29f94a30123 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_lists.pyi +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_lists.pyi @@ -1,16 +1,16 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar +from pylibcudf.utils import CudaStreamLike def format_list_column( input: Column, na_rep: Scalar | None = None, separators: Column | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_lists.pyx b/python/pylibcudf/pylibcudf/strings/convert/convert_lists.pyx index 79648efcc3f..9c8f9d7b02e 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_lists.pyx +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_lists.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -20,6 +20,7 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream from cython.operator import dereference +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["format_list_column"] @@ -27,7 +28,7 @@ cpdef Column format_list_column( Column input, Scalar na_rep=None, Column separators=None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -58,12 +59,13 @@ cpdef Column format_list_column( """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if na_rep is None: na_rep = Scalar.from_libcudf( - cpp_make_string_scalar("".encode(), stream.view(), mr.get_mr()) + cpp_make_string_scalar("".encode(), _stream.view().value(), mr.get_mr()) ) cdef const string_scalar* c_na_rep = ( @@ -78,8 +80,8 @@ cpdef Column format_list_column( input.view(), dereference(c_na_rep), separators.view(), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_urls.pxd b/python/pylibcudf/pylibcudf/strings/convert/convert_urls.pxd index dce44f5e547..56b1f803d38 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_urls.pxd +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_urls.pxd @@ -1,15 +1,14 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column url_encode( - Column Input, Stream stream=*, DeviceMemoryResource mr=* + Column Input, object stream = *, DeviceMemoryResource mr=* ) cpdef Column url_decode( - Column Input, Stream stream=*, DeviceMemoryResource mr=* + Column Input, object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_urls.pyi b/python/pylibcudf/pylibcudf/strings/convert/convert_urls.pyi index 6a248cdc974..8707da953b5 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_urls.pyi +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_urls.pyi @@ -1,18 +1,18 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column +from pylibcudf.utils import CudaStreamLike def url_encode( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def url_decode( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_urls.pyx b/python/pylibcudf/pylibcudf/strings/convert/convert_urls.pyx index 30ca51f27f7..efe009e6c02 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_urls.pyx +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_urls.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -10,10 +10,11 @@ from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["url_decode", "url_encode"] -cpdef Column url_encode(Column input, Stream stream=None, DeviceMemoryResource mr=None): +cpdef Column url_encode(Column input, object stream=None, DeviceMemoryResource mr=None): """ Encodes each string using URL encoding. @@ -33,16 +34,19 @@ cpdef Column url_encode(Column input, Stream stream=None, DeviceMemoryResource m New strings column. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_convert_urls.url_encode(input.view(), stream.view(), mr.get_mr()) + c_result = cpp_convert_urls.url_encode( + input.view(), _cs, mr.get_mr() + ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) -cpdef Column url_decode(Column input, Stream stream=None, DeviceMemoryResource mr=None): +cpdef Column url_decode(Column input, object stream=None, DeviceMemoryResource mr=None): """ Decodes each string using URL encoding. @@ -62,10 +66,13 @@ cpdef Column url_decode(Column input, Stream stream=None, DeviceMemoryResource m New strings column. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_convert_urls.url_decode(input.view(), stream.view(), mr.get_mr()) + c_result = cpp_convert_urls.url_decode( + input.view(), _cs, mr.get_mr() + ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/extract.pxd b/python/pylibcudf/pylibcudf/strings/extract.pxd index c8fcb900d2b..85f722970c8 100644 --- a/python/pylibcudf/pylibcudf/strings/extract.pxd +++ b/python/pylibcudf/pylibcudf/strings/extract.pxd @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column @@ -6,21 +6,20 @@ from pylibcudf.strings.regex_program cimport RegexProgram from pylibcudf.table cimport Table from pylibcudf.libcudf.types cimport size_type from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Table extract( - Column input, RegexProgram prog, Stream stream=*, DeviceMemoryResource mr=* + Column input, RegexProgram prog, object stream = *, DeviceMemoryResource mr=* ) cpdef Column extract_all_record( - Column input, RegexProgram prog, Stream stream=*, DeviceMemoryResource mr=* + Column input, RegexProgram prog, object stream = *, DeviceMemoryResource mr=* ) cpdef Column extract_single( Column input, RegexProgram prog, size_type group, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) diff --git a/python/pylibcudf/pylibcudf/strings/extract.pyi b/python/pylibcudf/pylibcudf/strings/extract.pyi index 853420a8091..a9607266bbc 100644 --- a/python/pylibcudf/pylibcudf/strings/extract.pyi +++ b/python/pylibcudf/pylibcudf/strings/extract.pyi @@ -1,29 +1,29 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.strings.regex_program import RegexProgram from pylibcudf.table import Table +from pylibcudf.utils import CudaStreamLike def extract( input: Column, prog: RegexProgram, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def extract_all_record( input: Column, prog: RegexProgram, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def extract_single( input: Column, prog: RegexProgram, group: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/extract.pyx b/python/pylibcudf/pylibcudf/strings/extract.pyx index bac20c2cd15..c670b226e84 100644 --- a/python/pylibcudf/pylibcudf/strings/extract.pyx +++ b/python/pylibcudf/pylibcudf/strings/extract.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -13,11 +13,12 @@ from pylibcudf.libcudf.types cimport size_type from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["extract", "extract_all_record", "extract_single"] cpdef Table extract( - Column input, RegexProgram prog, Stream stream=None, DeviceMemoryResource mr=None + Column input, RegexProgram prog, object stream=None, DeviceMemoryResource mr=None ): """ Returns a table of strings columns where each column @@ -41,22 +42,23 @@ cpdef Table extract( Columns of strings extracted from the input column. """ cdef unique_ptr[table] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_extract.extract( input.view(), prog.c_obj.get()[0], - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef Column extract_all_record( - Column input, RegexProgram prog, Stream stream=None, DeviceMemoryResource mr=None + Column input, RegexProgram prog, object stream=None, DeviceMemoryResource mr=None ): """ Returns a lists column of strings where each string column @@ -80,25 +82,26 @@ cpdef Column extract_all_record( Lists column containing strings extracted from the input column """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_extract.extract_all_record( input.view(), prog.c_obj.get()[0], - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column extract_single( Column input, RegexProgram prog, size_type group, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -124,7 +127,8 @@ cpdef Column extract_single( Column of strings extracted from the input column """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -132,8 +136,8 @@ cpdef Column extract_single( input.view(), prog.c_obj.get()[0], group, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/find.pxd b/python/pylibcudf/pylibcudf/strings/find.pxd index 3ec32563c5a..1a04cf4eca2 100644 --- a/python/pylibcudf/pylibcudf/strings/find.pxd +++ b/python/pylibcudf/pylibcudf/strings/find.pxd @@ -1,11 +1,10 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.libcudf.types cimport size_type from pylibcudf.scalar cimport Scalar from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream ctypedef fused ColumnOrScalar: Column @@ -16,7 +15,7 @@ cpdef Column find( ColumnOrScalar target, size_type start=*, size_type stop=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) @@ -25,27 +24,27 @@ cpdef Column rfind( Scalar target, size_type start=*, size_type stop=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef Column contains( Column input, ColumnOrScalar target, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef Column starts_with( Column input, ColumnOrScalar target, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef Column ends_with( Column input, ColumnOrScalar target, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) diff --git a/python/pylibcudf/pylibcudf/strings/find.pyi b/python/pylibcudf/pylibcudf/strings/find.pyi index a566fbdd72a..a8b3ca1da7c 100644 --- a/python/pylibcudf/pylibcudf/strings/find.pyi +++ b/python/pylibcudf/pylibcudf/strings/find.pyi @@ -1,18 +1,18 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar +from pylibcudf.utils import CudaStreamLike def find( input: Column, target: Column | Scalar, start: int = 0, stop: int = -1, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def rfind( @@ -20,24 +20,24 @@ def rfind( target: Scalar, start: int = 0, stop: int = -1, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def contains( input: Column, target: Column | Scalar, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def starts_with( input: Column, target: Column | Scalar, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def ends_with( input: Column, target: Column | Scalar, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/find.pyx b/python/pylibcudf/pylibcudf/strings/find.pyx index 7323a924342..102a8787651 100644 --- a/python/pylibcudf/pylibcudf/strings/find.pyx +++ b/python/pylibcudf/pylibcudf/strings/find.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr from libcpp.utility cimport move @@ -14,6 +14,7 @@ from rmm.pylibrmm.stream cimport Stream from cython.operator import dereference from pylibcudf.libcudf.scalar.scalar cimport string_scalar +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["contains", "ends_with", "find", "rfind", "starts_with"] @@ -22,7 +23,7 @@ cpdef Column find( ColumnOrScalar target, size_type start=0, size_type stop=-1, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Returns a column of character position values where the target string is @@ -58,7 +59,8 @@ cpdef Column find( New integer column with character position values """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if ColumnOrScalar is Column: with nogil: @@ -66,7 +68,7 @@ cpdef Column find( input.view(), target.view(), start, - stream.view(), + _cs, mr.get_mr() ) elif ColumnOrScalar is Scalar: @@ -76,13 +78,13 @@ cpdef Column find( dereference((target.c_obj.get())), start, stop, - stream.view(), + _cs, mr.get_mr() ) else: raise ValueError(f"Invalid target {target}") - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column rfind( @@ -90,7 +92,7 @@ cpdef Column rfind( Scalar target, size_type start=0, size_type stop=-1, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -119,7 +121,8 @@ cpdef Column rfind( New integer column with character position values """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: result = cpp_find.rfind( @@ -127,16 +130,16 @@ cpdef Column rfind( dereference((target.c_obj.get())), start, stop, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column contains( Column input, ColumnOrScalar target, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -169,14 +172,15 @@ cpdef Column contains( New boolean column with True for each string that contains the target """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if ColumnOrScalar is Column: with nogil: result = cpp_find.contains( input.view(), target.view(), - stream.view(), + _cs, mr.get_mr() ) elif ColumnOrScalar is Scalar: @@ -184,19 +188,19 @@ cpdef Column contains( result = cpp_find.contains( input.view(), dereference((target.c_obj.get())), - stream.view(), + _cs, mr.get_mr() ) else: raise ValueError(f"Invalid target {target}") - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column starts_with( Column input, ColumnOrScalar target, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -229,7 +233,8 @@ cpdef Column starts_with( New boolean column with True for each string that starts with the target """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if ColumnOrScalar is Column: @@ -237,7 +242,7 @@ cpdef Column starts_with( result = cpp_find.starts_with( input.view(), target.view(), - stream.view(), + _cs, mr.get_mr() ) elif ColumnOrScalar is Scalar: @@ -245,18 +250,18 @@ cpdef Column starts_with( result = cpp_find.starts_with( input.view(), dereference((target.c_obj.get())), - stream.view(), + _cs, mr.get_mr() ) else: raise ValueError(f"Invalid target {target}") - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column ends_with( Column input, ColumnOrScalar target, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -288,14 +293,15 @@ cpdef Column ends_with( New boolean column with True for each string that ends with the target """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if ColumnOrScalar is Column: with nogil: result = cpp_find.ends_with( input.view(), target.view(), - stream.view(), + _cs, mr.get_mr() ) elif ColumnOrScalar is Scalar: @@ -303,10 +309,10 @@ cpdef Column ends_with( result = cpp_find.ends_with( input.view(), dereference((target.c_obj.get())), - stream.view(), + _cs, mr.get_mr() ) else: raise ValueError(f"Invalid target {target}") - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/find_multiple.pxd b/python/pylibcudf/pylibcudf/strings/find_multiple.pxd index f6677607c5e..e01cb33fdb8 100644 --- a/python/pylibcudf/pylibcudf/strings/find_multiple.pxd +++ b/python/pylibcudf/pylibcudf/strings/find_multiple.pxd @@ -1,21 +1,20 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.table cimport Table from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column find_multiple( Column input, Column targets, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef Table contains_multiple( Column input, Column targets, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) diff --git a/python/pylibcudf/pylibcudf/strings/find_multiple.pyi b/python/pylibcudf/pylibcudf/strings/find_multiple.pyi index 48de0eac0e1..76115cd7496 100644 --- a/python/pylibcudf/pylibcudf/strings/find_multiple.pyi +++ b/python/pylibcudf/pylibcudf/strings/find_multiple.pyi @@ -1,21 +1,21 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.table import Table +from pylibcudf.utils import CudaStreamLike def find_multiple( input: Column, targets: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def contains_multiple( input: Column, targets: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... diff --git a/python/pylibcudf/pylibcudf/strings/find_multiple.pyx b/python/pylibcudf/pylibcudf/strings/find_multiple.pyx index e18b178f803..ed5f0d78506 100644 --- a/python/pylibcudf/pylibcudf/strings/find_multiple.pyx +++ b/python/pylibcudf/pylibcudf/strings/find_multiple.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2020-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -11,13 +11,14 @@ from pylibcudf.table cimport Table from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["find_multiple", "contains_multiple"] cpdef Column find_multiple( Column input, Column targets, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -41,24 +42,25 @@ cpdef Column find_multiple( Lists column with character position values """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_find_multiple.find_multiple( input.view(), targets.view(), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Table contains_multiple( Column input, Column targets, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -82,15 +84,16 @@ cpdef Table contains_multiple( Columns of booleans """ cdef unique_ptr[table] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_find_multiple.contains_multiple( input.view(), targets.view(), - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/findall.pxd b/python/pylibcudf/pylibcudf/strings/findall.pxd index 2dc75fa6d34..ec7e01f7539 100644 --- a/python/pylibcudf/pylibcudf/strings/findall.pxd +++ b/python/pylibcudf/pylibcudf/strings/findall.pxd @@ -1,15 +1,14 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.strings.regex_program cimport RegexProgram from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column find_re( - Column input, RegexProgram pattern, Stream stream=*, DeviceMemoryResource mr=* + Column input, RegexProgram pattern, object stream = *, DeviceMemoryResource mr=* ) cpdef Column findall( - Column input, RegexProgram pattern, Stream stream=*, DeviceMemoryResource mr=* + Column input, RegexProgram pattern, object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/strings/findall.pyi b/python/pylibcudf/pylibcudf/strings/findall.pyi index 5677a99d325..f72e786cf1d 100644 --- a/python/pylibcudf/pylibcudf/strings/findall.pyi +++ b/python/pylibcudf/pylibcudf/strings/findall.pyi @@ -1,21 +1,21 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.strings.regex_program import RegexProgram +from pylibcudf.utils import CudaStreamLike def find_re( input: Column, pattern: RegexProgram, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def findall( input: Column, pattern: RegexProgram, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/findall.pyx b/python/pylibcudf/pylibcudf/strings/findall.pyx index 881664faced..5647a791ef1 100644 --- a/python/pylibcudf/pylibcudf/strings/findall.pyx +++ b/python/pylibcudf/pylibcudf/strings/findall.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -10,11 +10,12 @@ from pylibcudf.strings.regex_program cimport RegexProgram from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["findall", "find_re"] cpdef Column findall( - Column input, RegexProgram pattern, Stream stream=None, DeviceMemoryResource mr=None + Column input, RegexProgram pattern, object stream=None, DeviceMemoryResource mr=None ): """ Returns a lists column of strings for each matching occurrence using @@ -37,22 +38,23 @@ cpdef Column findall( New lists column of strings """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_findall.findall( input.view(), pattern.c_obj.get()[0], - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column find_re( - Column input, RegexProgram pattern, Stream stream=None, DeviceMemoryResource mr=None + Column input, RegexProgram pattern, object stream=None, DeviceMemoryResource mr=None ): """ Returns character positions where the pattern first matches @@ -75,15 +77,16 @@ cpdef Column find_re( New column of integers """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_findall.find_re( input.view(), pattern.c_obj.get()[0], - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/padding.pxd b/python/pylibcudf/pylibcudf/strings/padding.pxd index 1dfbbd9950f..61dcaf7cba9 100644 --- a/python/pylibcudf/pylibcudf/strings/padding.pxd +++ b/python/pylibcudf/pylibcudf/strings/padding.pxd @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.string cimport string @@ -6,7 +6,6 @@ from pylibcudf.column cimport Column from pylibcudf.libcudf.strings.side_type cimport side_type from pylibcudf.libcudf.types cimport size_type from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column pad( @@ -14,14 +13,14 @@ cpdef Column pad( size_type width, side_type side, str fill_char, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef Column zfill( - Column input, size_type width, Stream stream=*, DeviceMemoryResource mr=* + Column input, size_type width, object stream = *, DeviceMemoryResource mr=* ) cpdef Column zfill_by_widths( - Column input, Column widths, Stream stream=*, DeviceMemoryResource mr=* + Column input, Column widths, object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/strings/padding.pyi b/python/pylibcudf/pylibcudf/strings/padding.pyi index 26af5429acb..904b0022317 100644 --- a/python/pylibcudf/pylibcudf/strings/padding.pyi +++ b/python/pylibcudf/pylibcudf/strings/padding.pyi @@ -1,29 +1,29 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.strings.side_type import SideType +from pylibcudf.utils import CudaStreamLike def pad( input: Column, width: int, side: SideType, fill_char: str, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def zfill( input: Column, width: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def zfill_by_widths( input: Column, widths: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/padding.pyx b/python/pylibcudf/pylibcudf/strings/padding.pyx index 9409970b075..d8eb4f1da4a 100644 --- a/python/pylibcudf/pylibcudf/strings/padding.pyx +++ b/python/pylibcudf/pylibcudf/strings/padding.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr from libcpp.utility cimport move @@ -10,6 +10,7 @@ from pylibcudf.libcudf.types cimport size_type from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["pad", "zfill", "zfill_by_widths"] @@ -18,7 +19,7 @@ cpdef Column pad( size_type width, side_type side, str fill_char, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -46,7 +47,8 @@ cpdef Column pad( """ cdef unique_ptr[column] c_result cdef string c_fill_char = fill_char.encode("utf-8") - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -55,14 +57,14 @@ cpdef Column pad( width, side, c_fill_char, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column zfill( - Column input, size_type width, Stream stream=None, DeviceMemoryResource mr=None + Column input, size_type width, object stream=None, DeviceMemoryResource mr=None ): """ Add '0' as padding to the left of each string. @@ -84,21 +86,22 @@ cpdef Column zfill( New column of strings. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_padding.zfill( input.view(), width, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column zfill_by_widths( - Column input, Column widths, Stream stream=None, DeviceMemoryResource mr=None + Column input, Column widths, object stream=None, DeviceMemoryResource mr=None ): """ Add '0' as padding to the left of each string. @@ -120,15 +123,16 @@ cpdef Column zfill_by_widths( New column of strings. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_padding.zfill_by_widths( input.view(), widths.view(), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/repeat.pxd b/python/pylibcudf/pylibcudf/strings/repeat.pxd index f1abe23ce59..60725aa688e 100644 --- a/python/pylibcudf/pylibcudf/strings/repeat.pxd +++ b/python/pylibcudf/pylibcudf/strings/repeat.pxd @@ -1,10 +1,9 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.libcudf.types cimport size_type from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream ctypedef fused ColumnorSizeType: Column @@ -13,6 +12,6 @@ ctypedef fused ColumnorSizeType: cpdef Column repeat_strings( Column input, ColumnorSizeType repeat_times, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) diff --git a/python/pylibcudf/pylibcudf/strings/repeat.pyi b/python/pylibcudf/pylibcudf/strings/repeat.pyi index 5b47213e956..fedb7dee76c 100644 --- a/python/pylibcudf/pylibcudf/strings/repeat.pyi +++ b/python/pylibcudf/pylibcudf/strings/repeat.pyi @@ -1,14 +1,14 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column +from pylibcudf.utils import CudaStreamLike def repeat_strings( input: Column, repeat_times: Column | int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/repeat.pyx b/python/pylibcudf/pylibcudf/strings/repeat.pyx index 84a305bf866..7a9c5285d02 100644 --- a/python/pylibcudf/pylibcudf/strings/repeat.pyx +++ b/python/pylibcudf/pylibcudf/strings/repeat.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr from libcpp.utility cimport move @@ -11,13 +11,14 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream from ..utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["repeat_strings"] cpdef Column repeat_strings( Column input, ColumnorSizeType repeat_times, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -44,7 +45,8 @@ cpdef Column repeat_strings( New column containing the repeated strings. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if ColumnorSizeType is Column: @@ -52,7 +54,7 @@ cpdef Column repeat_strings( c_result = cpp_repeat.repeat_strings( input.view(), repeat_times.view(), - stream.view(), + _cs, mr.get_mr() ) elif ColumnorSizeType is size_type: @@ -60,10 +62,10 @@ cpdef Column repeat_strings( c_result = cpp_repeat.repeat_strings( input.view(), repeat_times, - stream.view(), + _cs, mr.get_mr() ) else: raise ValueError("repeat_times must be size_type or integer") - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/replace.pxd b/python/pylibcudf/pylibcudf/strings/replace.pxd index a486869aada..aea2296b5f9 100644 --- a/python/pylibcudf/pylibcudf/strings/replace.pxd +++ b/python/pylibcudf/pylibcudf/strings/replace.pxd @@ -1,11 +1,10 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.libcudf.types cimport size_type from pylibcudf.scalar cimport Scalar from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column replace( @@ -13,7 +12,7 @@ cpdef Column replace( Scalar target, Scalar repl, size_type maxrepl=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef Column replace_multiple( @@ -21,7 +20,7 @@ cpdef Column replace_multiple( Column target, Column repl, size_type maxrepl=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) cpdef Column replace_slice( @@ -29,6 +28,6 @@ cpdef Column replace_slice( Scalar repl=*, size_type start=*, size_type stop=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=*, ) diff --git a/python/pylibcudf/pylibcudf/strings/replace.pyi b/python/pylibcudf/pylibcudf/strings/replace.pyi index 3e62a76d2bf..0e76eb402f7 100644 --- a/python/pylibcudf/pylibcudf/strings/replace.pyi +++ b/python/pylibcudf/pylibcudf/strings/replace.pyi @@ -1,18 +1,18 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar +from pylibcudf.utils import CudaStreamLike def replace( input: Column, target: Scalar, repl: Scalar, maxrepl: int = -1, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def replace_multiple( @@ -20,7 +20,7 @@ def replace_multiple( target: Column, repl: Column, maxrepl: int = -1, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def replace_slice( @@ -28,6 +28,6 @@ def replace_slice( repl: Scalar | None = None, start: int = 0, stop: int = -1, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/replace.pyx b/python/pylibcudf/pylibcudf/strings/replace.pyx index e1d88fed464..ccd6c924441 100644 --- a/python/pylibcudf/pylibcudf/strings/replace.pyx +++ b/python/pylibcudf/pylibcudf/strings/replace.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -19,6 +19,7 @@ from pylibcudf.scalar cimport Scalar from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["replace", "replace_multiple", "replace_slice"] @@ -27,7 +28,7 @@ cpdef Column replace( Scalar target, Scalar repl, size_type maxrepl=-1, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Replaces target string within each string with the specified replacement string. @@ -60,7 +61,8 @@ cpdef Column replace( target_str = (target.c_obj.get()) repl_str = (repl.c_obj.get()) - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -69,11 +71,11 @@ cpdef Column replace( target_str[0], repl_str[0], maxrepl, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column replace_multiple( @@ -81,7 +83,7 @@ cpdef Column replace_multiple( Column target, Column repl, size_type maxrepl=-1, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Replaces target string within each string with the specified replacement string. @@ -109,7 +111,8 @@ cpdef Column replace_multiple( New string column with target replaced. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -117,11 +120,11 @@ cpdef Column replace_multiple( input.view(), target.view(), repl.view(), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column replace_slice( @@ -131,7 +134,7 @@ cpdef Column replace_slice( Scalar repl=None, size_type start=0, size_type stop=-1, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Replaces each string in the column with the provided repl string @@ -162,12 +165,13 @@ cpdef Column replace_slice( New string column """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if repl is None: repl = Scalar.from_libcudf( - cpp_make_string_scalar("".encode(), stream.view(), mr.get_mr()) + cpp_make_string_scalar("".encode(), _stream.view().value(), mr.get_mr()) ) cdef const string_scalar* scalar_str = (repl.c_obj.get()) @@ -178,8 +182,8 @@ cpdef Column replace_slice( scalar_str[0], start, stop, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/replace_re.pxd b/python/pylibcudf/pylibcudf/strings/replace_re.pxd index fc833a61045..0d360f8de6f 100644 --- a/python/pylibcudf/pylibcudf/strings/replace_re.pxd +++ b/python/pylibcudf/pylibcudf/strings/replace_re.pxd @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column @@ -7,7 +7,6 @@ from pylibcudf.scalar cimport Scalar from pylibcudf.strings.regex_flags cimport regex_flags from pylibcudf.strings.regex_program cimport RegexProgram from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream ctypedef fused Replacement: Column @@ -24,7 +23,7 @@ cpdef Column replace_re( Replacement replacement=*, size_type max_replace_count=*, regex_flags flags=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) @@ -32,6 +31,6 @@ cpdef Column replace_with_backrefs( Column input, RegexProgram prog, str replacement, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/strings/replace_re.pyi b/python/pylibcudf/pylibcudf/strings/replace_re.pyi index 29f8ddfe925..64970928323 100644 --- a/python/pylibcudf/pylibcudf/strings/replace_re.pyi +++ b/python/pylibcudf/pylibcudf/strings/replace_re.pyi @@ -1,15 +1,15 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from typing import overload from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar from pylibcudf.strings.regex_flags import RegexFlags from pylibcudf.strings.regex_program import RegexProgram +from pylibcudf.utils import CudaStreamLike @overload def replace_re( @@ -17,7 +17,7 @@ def replace_re( pattern: RegexProgram, replacement: Scalar, max_replace_count: int = -1, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... @overload @@ -27,13 +27,13 @@ def replace_re( replacement: Column, max_replace_count: int = -1, flags: RegexFlags = RegexFlags.DEFAULT, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def replace_with_backrefs( input: Column, prog: RegexProgram, replacement: str, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/replace_re.pyx b/python/pylibcudf/pylibcudf/strings/replace_re.pyx index 1819dd0ba2b..60e9c4c1666 100644 --- a/python/pylibcudf/pylibcudf/strings/replace_re.pyx +++ b/python/pylibcudf/pylibcudf/strings/replace_re.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from cython.operator cimport dereference from libcpp.memory cimport unique_ptr @@ -19,6 +19,7 @@ from pylibcudf.strings.regex_program cimport RegexProgram from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["replace_re", "replace_with_backrefs"] @@ -28,7 +29,7 @@ cpdef Column replace_re( Replacement replacement=None, size_type max_replace_count=-1, regex_flags flags=regex_flags.DEFAULT, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -64,13 +65,14 @@ cpdef Column replace_re( """ cdef unique_ptr[column] c_result cdef vector[string] c_patterns - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if Patterns is RegexProgram and Replacement is Scalar: if replacement is None: replacement = Scalar.from_libcudf( - cpp_make_string_scalar("".encode(), stream.view(), mr.get_mr()) + cpp_make_string_scalar("".encode(), _stream.view().value(), mr.get_mr()) ) with nogil: c_result = move( @@ -79,12 +81,12 @@ cpdef Column replace_re( patterns.c_obj.get()[0], dereference((replacement.get())), max_replace_count, - stream.view(), + _cs, mr.get_mr() ) ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) elif Patterns is list and Replacement is Column: c_patterns.reserve(len(patterns)) for pattern in patterns: @@ -97,12 +99,12 @@ cpdef Column replace_re( c_patterns, replacement.view(), flags, - stream.view(), + _cs, mr.get_mr() ) ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) else: raise TypeError("Must pass either a RegexProgram and a Scalar or a list") @@ -111,7 +113,7 @@ cpdef Column replace_with_backrefs( Column input, RegexProgram prog, str replacement, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -137,7 +139,8 @@ cpdef Column replace_with_backrefs( New strings column. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) cdef string c_replacement = replacement.encode() @@ -146,8 +149,8 @@ cpdef Column replace_with_backrefs( input.view(), prog.c_obj.get()[0], c_replacement, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/reverse.pyi b/python/pylibcudf/pylibcudf/strings/reverse.pyi index 182f4768825..48c602e2d28 100644 --- a/python/pylibcudf/pylibcudf/strings/reverse.pyi +++ b/python/pylibcudf/pylibcudf/strings/reverse.pyi @@ -1,13 +1,13 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column +from pylibcudf.utils import CudaStreamLike def reverse( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/reverse.pyx b/python/pylibcudf/pylibcudf/strings/reverse.pyx index 49792b5661b..f1d06248523 100644 --- a/python/pylibcudf/pylibcudf/strings/reverse.pyx +++ b/python/pylibcudf/pylibcudf/strings/reverse.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -9,10 +9,11 @@ from pylibcudf.libcudf.strings cimport reverse as cpp_reverse from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["reverse"] -cpdef Column reverse(Column input, Stream stream=None, DeviceMemoryResource mr=None): +cpdef Column reverse(Column input, object stream=None, DeviceMemoryResource mr=None): """Reverses the characters within each string. Any null string entries return corresponding null output column entries. @@ -32,9 +33,10 @@ cpdef Column reverse(Column input, Stream stream=None, DeviceMemoryResource mr=N New strings column """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_reverse.reverse(input.view(), stream.view(), mr.get_mr()) + c_result = cpp_reverse.reverse(input.view(), _cs, mr.get_mr()) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/slice.pxd b/python/pylibcudf/pylibcudf/strings/slice.pxd index 6bb5a8d3611..9612ead3108 100644 --- a/python/pylibcudf/pylibcudf/strings/slice.pxd +++ b/python/pylibcudf/pylibcudf/strings/slice.pxd @@ -1,10 +1,9 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.scalar cimport Scalar from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream ctypedef fused ColumnOrScalar: Column @@ -15,6 +14,6 @@ cpdef Column slice_strings( ColumnOrScalar start=*, ColumnOrScalar stop=*, Scalar step=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/strings/slice.pyi b/python/pylibcudf/pylibcudf/strings/slice.pyi index 73ee8c31b5b..ac2e4d12f1f 100644 --- a/python/pylibcudf/pylibcudf/strings/slice.pyi +++ b/python/pylibcudf/pylibcudf/strings/slice.pyi @@ -1,17 +1,17 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar +from pylibcudf.utils import CudaStreamLike def slice_strings( input: Column, start: Column | Scalar | None = None, stop: Column | Scalar | None = None, step: Scalar | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/slice.pyx b/python/pylibcudf/pylibcudf/strings/slice.pyx index 2b5bbf2f621..b3ac2cd8bfe 100644 --- a/python/pylibcudf/pylibcudf/strings/slice.pyx +++ b/python/pylibcudf/pylibcudf/strings/slice.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -18,6 +18,7 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream from ..utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["slice_strings"] @@ -26,7 +27,7 @@ cpdef Column slice_strings( ColumnOrScalar start=None, ColumnOrScalar stop=None, Scalar step=None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Perform a slice operation on a strings column. @@ -60,7 +61,8 @@ cpdef Column slice_strings( cdef numeric_scalar[size_type]* cpp_start cdef numeric_scalar[size_type]* cpp_stop cdef numeric_scalar[size_type]* cpp_step - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if input is None: @@ -80,22 +82,22 @@ cpdef Column slice_strings( input.view(), start.view(), stop.view(), - stream.view(), + _cs, mr.get_mr() ) elif ColumnOrScalar is Scalar: if start is None: start = Scalar.from_libcudf( - cpp_make_fixed_width_scalar(0, stream.view(), mr.get_mr()) + cpp_make_fixed_width_scalar(0, _stream.view().value(), mr.get_mr()) ) if stop is None: stop = Scalar.from_libcudf( - cpp_make_fixed_width_scalar(0, stream.view(), mr.get_mr()) + cpp_make_fixed_width_scalar(0, _stream.view().value(), mr.get_mr()) ) if step is None: step = Scalar.from_libcudf( - cpp_make_fixed_width_scalar(1, stream.view(), mr.get_mr()) + cpp_make_fixed_width_scalar(1, _stream.view().value(), mr.get_mr()) ) cpp_start = start.c_obj.get() @@ -108,10 +110,10 @@ cpdef Column slice_strings( dereference(cpp_start), dereference(cpp_stop), dereference(cpp_step), - stream.view(), + _cs, mr.get_mr() ) else: raise ValueError("start, stop, and step must be either Column or Scalar") - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/split/partition.pxd b/python/pylibcudf/pylibcudf/strings/split/partition.pxd index d8001682b32..e3da533c90c 100644 --- a/python/pylibcudf/pylibcudf/strings/split/partition.pxd +++ b/python/pylibcudf/pylibcudf/strings/split/partition.pxd @@ -1,17 +1,16 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.scalar cimport Scalar from pylibcudf.table cimport Table from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Table partition( - Column input, Scalar delimiter=*, Stream stream=*, DeviceMemoryResource mr=* + Column input, Scalar delimiter=*, object stream = *, DeviceMemoryResource mr=* ) cpdef Table rpartition( - Column input, Scalar delimiter=*, Stream stream=*, DeviceMemoryResource mr=* + Column input, Scalar delimiter=*, object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/strings/split/partition.pyi b/python/pylibcudf/pylibcudf/strings/split/partition.pyi index d919b68153c..cef2d16aea6 100644 --- a/python/pylibcudf/pylibcudf/strings/split/partition.pyi +++ b/python/pylibcudf/pylibcudf/strings/split/partition.pyi @@ -1,22 +1,22 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar from pylibcudf.table import Table +from pylibcudf.utils import CudaStreamLike def partition( input: Column, delimiter: Scalar | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def rpartition( input: Column, delimiter: Scalar | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... diff --git a/python/pylibcudf/pylibcudf/strings/split/partition.pyx b/python/pylibcudf/pylibcudf/strings/split/partition.pyx index 728d7b9975d..ce813c10bba 100644 --- a/python/pylibcudf/pylibcudf/strings/split/partition.pyx +++ b/python/pylibcudf/pylibcudf/strings/split/partition.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr from libcpp.utility cimport move @@ -16,13 +16,14 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream from cython.operator import dereference +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["partition", "rpartition"] cpdef Table partition( Column input, Scalar delimiter=None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -46,12 +47,13 @@ cpdef Table partition( """ cdef unique_ptr[table] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if delimiter is None: delimiter = Scalar.from_libcudf( - cpp_make_string_scalar("".encode(), stream.view(), mr.get_mr()) + cpp_make_string_scalar("".encode(), _stream.view().value(), mr.get_mr()) ) cdef const string_scalar* c_delimiter = ( @@ -62,16 +64,16 @@ cpdef Table partition( c_result = cpp_partition.partition( input.view(), dereference(c_delimiter), - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef Table rpartition( Column input, Scalar delimiter=None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -95,12 +97,13 @@ cpdef Table rpartition( """ cdef unique_ptr[table] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if delimiter is None: delimiter = Scalar.from_libcudf( - cpp_make_string_scalar("".encode(), stream.view(), mr.get_mr()) + cpp_make_string_scalar("".encode(), _stream.view().value(), mr.get_mr()) ) cdef const string_scalar* c_delimiter = ( @@ -111,8 +114,8 @@ cpdef Table rpartition( c_result = cpp_partition.rpartition( input.view(), dereference(c_delimiter), - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/split/split.pxd b/python/pylibcudf/pylibcudf/strings/split/split.pxd index 06b77154b18..2372a177944 100644 --- a/python/pylibcudf/pylibcudf/strings/split/split.pxd +++ b/python/pylibcudf/pylibcudf/strings/split/split.pxd @@ -7,50 +7,49 @@ from pylibcudf.scalar cimport Scalar from pylibcudf.strings.regex_program cimport RegexProgram from pylibcudf.table cimport Table from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Table split( - Column strings_column, Scalar delimiter, size_type maxsplit, Stream stream=*, + Column strings_column, Scalar delimiter, size_type maxsplit, object stream = *, DeviceMemoryResource mr=*, ) cpdef Table rsplit( - Column strings_column, Scalar delimiter, size_type maxsplit, Stream stream=*, + Column strings_column, Scalar delimiter, size_type maxsplit, object stream = *, DeviceMemoryResource mr=*, ) cpdef Column split_record( - Column strings, Scalar delimiter, size_type maxsplit, Stream stream=*, + Column strings, Scalar delimiter, size_type maxsplit, object stream = *, DeviceMemoryResource mr=*, ) cpdef Column rsplit_record( - Column strings, Scalar delimiter, size_type maxsplit, Stream stream=*, + Column strings, Scalar delimiter, size_type maxsplit, object stream = *, DeviceMemoryResource mr=*, ) cpdef Table split_re( - Column input, RegexProgram prog, size_type maxsplit, Stream stream=*, + Column input, RegexProgram prog, size_type maxsplit, object stream = *, DeviceMemoryResource mr=*, ) cpdef Table rsplit_re( - Column input, RegexProgram prog, size_type maxsplit, Stream stream=*, + Column input, RegexProgram prog, size_type maxsplit, object stream = *, DeviceMemoryResource mr=*, ) cpdef Column split_record_re( - Column input, RegexProgram prog, size_type maxsplit, Stream stream=*, + Column input, RegexProgram prog, size_type maxsplit, object stream = *, DeviceMemoryResource mr=*, ) cpdef Column rsplit_record_re( - Column input, RegexProgram prog, size_type maxsplit, Stream stream=*, + Column input, RegexProgram prog, size_type maxsplit, object stream = *, DeviceMemoryResource mr=*, ) cpdef Column split_part( - Column input, Scalar delimiter, size_type index, Stream stream=*, + Column input, Scalar delimiter, size_type index, object stream = *, DeviceMemoryResource mr=*, ) diff --git a/python/pylibcudf/pylibcudf/strings/split/split.pyi b/python/pylibcudf/pylibcudf/strings/split/split.pyi index ae64e300b63..7a775bd960c 100644 --- a/python/pylibcudf/pylibcudf/strings/split/split.pyi +++ b/python/pylibcudf/pylibcudf/strings/split/split.pyi @@ -2,73 +2,73 @@ # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar from pylibcudf.strings.regex_program import RegexProgram from pylibcudf.table import Table +from pylibcudf.utils import CudaStreamLike def split( strings_column: Column, delimiter: Scalar, maxsplit: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def rsplit( strings_column: Column, delimiter: Scalar, maxsplit: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def split_record( strings: Column, delimiter: Scalar, maxsplit: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def rsplit_record( strings: Column, delimiter: Scalar, maxsplit: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def split_re( input: Column, prog: RegexProgram, maxsplit: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def rsplit_re( input: Column, prog: RegexProgram, maxsplit: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def split_record_re( input: Column, prog: RegexProgram, maxsplit: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def rsplit_record_re( input: Column, prog: RegexProgram, maxsplit: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def split_part( input: Column, delimiter: Scalar, index: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/split/split.pyx b/python/pylibcudf/pylibcudf/strings/split/split.pyx index 0635df87e13..52803b08eb0 100644 --- a/python/pylibcudf/pylibcudf/strings/split/split.pyx +++ b/python/pylibcudf/pylibcudf/strings/split/split.pyx @@ -16,6 +16,7 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream from cython.operator import dereference +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "rsplit", @@ -32,7 +33,7 @@ cpdef Table split( Column strings_column, Scalar delimiter, size_type maxsplit, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -65,7 +66,8 @@ cpdef Table split( cdef const string_scalar* c_delimiter = ( delimiter.c_obj.get() ) - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -73,18 +75,18 @@ cpdef Table split( strings_column.view(), dereference(c_delimiter), maxsplit, - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef Table rsplit( Column strings_column, Scalar delimiter, size_type maxsplit, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -117,7 +119,8 @@ cpdef Table rsplit( cdef const string_scalar* c_delimiter = ( delimiter.c_obj.get() ) - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -125,17 +128,17 @@ cpdef Table rsplit( strings_column.view(), dereference(c_delimiter), maxsplit, - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef Column split_record( Column strings, Scalar delimiter, size_type maxsplit, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -164,7 +167,8 @@ cpdef Column split_record( cdef const string_scalar* c_delimiter = ( delimiter.c_obj.get() ) - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -172,18 +176,18 @@ cpdef Column split_record( strings.view(), dereference(c_delimiter), maxsplit, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column rsplit_record( Column strings, Scalar delimiter, size_type maxsplit, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -213,7 +217,8 @@ cpdef Column rsplit_record( cdef const string_scalar* c_delimiter = ( delimiter.c_obj.get() ) - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -221,18 +226,18 @@ cpdef Column rsplit_record( strings.view(), dereference(c_delimiter), maxsplit, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Table split_re( Column input, RegexProgram prog, size_type maxsplit, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -259,7 +264,8 @@ cpdef Table split_re( A table of columns of strings. """ cdef unique_ptr[table] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -267,17 +273,17 @@ cpdef Table split_re( input.view(), prog.c_obj.get()[0], maxsplit, - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef Table rsplit_re( Column input, RegexProgram prog, size_type maxsplit, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -305,7 +311,8 @@ cpdef Table rsplit_re( A table of columns of strings. """ cdef unique_ptr[table] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -313,17 +320,17 @@ cpdef Table rsplit_re( input.view(), prog.c_obj.get()[0], maxsplit, - stream.view(), + _cs, mr.get_mr() ) - return Table.from_libcudf(move(c_result), stream, mr) + return Table.from_libcudf(move(c_result), _stream, mr) cpdef Column split_record_re( Column input, RegexProgram prog, size_type maxsplit, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -350,7 +357,8 @@ cpdef Column split_record_re( Lists column of strings. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -358,14 +366,14 @@ cpdef Column split_record_re( input.view(), prog.c_obj.get()[0], maxsplit, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column rsplit_record_re( - Column input, RegexProgram prog, size_type maxsplit, Stream stream=None, + Column input, RegexProgram prog, size_type maxsplit, object stream=None, DeviceMemoryResource mr=None, ): """ @@ -392,7 +400,8 @@ cpdef Column rsplit_record_re( Lists column of strings. """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -400,22 +409,23 @@ cpdef Column rsplit_record_re( input.view(), prog.c_obj.get()[0], maxsplit, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column split_part( - Column input, Scalar delimiter, size_type index, Stream stream=None, + Column input, Scalar delimiter, size_type index, object stream=None, DeviceMemoryResource mr=None, ): cdef unique_ptr[column] c_result cdef const string_scalar* c_delimiter = ( delimiter.c_obj.get() ) - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -423,8 +433,8 @@ cpdef Column split_part( input.view(), dereference(c_delimiter), index, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/strip.pxd b/python/pylibcudf/pylibcudf/strings/strip.pxd index d3f41ce9a5c..a37ac40c523 100644 --- a/python/pylibcudf/pylibcudf/strings/strip.pxd +++ b/python/pylibcudf/pylibcudf/strings/strip.pxd @@ -1,17 +1,16 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.scalar cimport Scalar from pylibcudf.strings.side_type cimport side_type from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column strip( Column input, side_type side=*, Scalar to_strip=*, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/strings/strip.pyi b/python/pylibcudf/pylibcudf/strings/strip.pyi index ecb80b632d7..786079769c7 100644 --- a/python/pylibcudf/pylibcudf/strings/strip.pyi +++ b/python/pylibcudf/pylibcudf/strings/strip.pyi @@ -1,17 +1,17 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar from pylibcudf.strings.side_type import SideType +from pylibcudf.utils import CudaStreamLike def strip( input: Column, side: SideType = SideType.BOTH, to_strip: Scalar | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/strip.pyx b/python/pylibcudf/pylibcudf/strings/strip.pyx index 3b477fa83ad..607428b6f69 100644 --- a/python/pylibcudf/pylibcudf/strings/strip.pyx +++ b/python/pylibcudf/pylibcudf/strings/strip.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from cython.operator cimport dereference @@ -16,6 +16,7 @@ from pylibcudf.strings.side_type cimport side_type from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["strip"] @@ -23,7 +24,7 @@ cpdef Column strip( Column input, side_type side=side_type.BOTH, Scalar to_strip=None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Removes the specified characters from the beginning @@ -47,12 +48,13 @@ cpdef Column strip( pylibcudf.Column New strings column. """ - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if to_strip is None: to_strip = Scalar.from_libcudf( - cpp_make_string_scalar("".encode(), stream.view(), mr.get_mr()) + cpp_make_string_scalar("".encode(), _stream.view().value(), mr.get_mr()) ) cdef unique_ptr[column] c_result @@ -64,8 +66,8 @@ cpdef Column strip( input.view(), side, dereference(cpp_to_strip), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/strings/translate.pxd b/python/pylibcudf/pylibcudf/strings/translate.pxd index 2d74e2f4a2c..d6a80ddfd43 100644 --- a/python/pylibcudf/pylibcudf/strings/translate.pxd +++ b/python/pylibcudf/pylibcudf/strings/translate.pxd @@ -1,14 +1,13 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.libcudf.strings.translate cimport filter_type from pylibcudf.scalar cimport Scalar from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column translate( - Column input, dict chars_table, Stream stream=*, DeviceMemoryResource mr=* + Column input, dict chars_table, object stream = *, DeviceMemoryResource mr=* ) cpdef Column filter_characters( @@ -16,6 +15,6 @@ cpdef Column filter_characters( dict characters_to_filter, filter_type keep_characters, Scalar replacement, - Stream stream=*, + object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/strings/translate.pyi b/python/pylibcudf/pylibcudf/strings/translate.pyi index a01b786fd6f..9e7624e0b17 100644 --- a/python/pylibcudf/pylibcudf/strings/translate.pyi +++ b/python/pylibcudf/pylibcudf/strings/translate.pyi @@ -1,13 +1,13 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from collections.abc import Mapping from enum import IntEnum from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.scalar import Scalar +from pylibcudf.utils import CudaStreamLike class FilterType(IntEnum): KEEP = ... @@ -16,7 +16,7 @@ class FilterType(IntEnum): def translate( input: Column, chars_table: Mapping[int | str, int | str], - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def filter_characters( @@ -24,6 +24,6 @@ def filter_characters( characters_to_filter: Mapping[int | str, int | str], keep_characters: FilterType, replacement: Scalar, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/translate.pyx b/python/pylibcudf/pylibcudf/strings/translate.pyx index 06c772330df..2a60ff881d4 100644 --- a/python/pylibcudf/pylibcudf/strings/translate.pyx +++ b/python/pylibcudf/pylibcudf/strings/translate.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr from libcpp.pair cimport pair @@ -15,6 +15,7 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream from cython.operator import dereference +from cuda.bindings.cyruntime cimport cudaStream_t from pylibcudf.libcudf.strings.translate import \ filter_type as FilterType # no-cython-lint @@ -43,7 +44,7 @@ cdef vector[pair[char_utf8, char_utf8]] _table_to_c_table(dict table): cpdef Column translate( - Column input, dict chars_table, Stream stream=None, DeviceMemoryResource mr=None + Column input, dict chars_table, object stream=None, DeviceMemoryResource mr=None ): """ Translates individual characters within each string. @@ -69,17 +70,18 @@ cpdef Column translate( cdef vector[pair[char_utf8, char_utf8]] c_chars_table = _table_to_c_table( chars_table ) - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_translate.translate( input.view(), c_chars_table, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column filter_characters( @@ -87,7 +89,7 @@ cpdef Column filter_characters( dict characters_to_filter, filter_type keep_characters, Scalar replacement, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """ @@ -124,7 +126,8 @@ cpdef Column filter_characters( cdef const string_scalar* c_replacement = ( replacement.c_obj.get() ) - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -133,9 +136,9 @@ cpdef Column filter_characters( c_characters_to_filter, keep_characters, dereference(c_replacement), - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) FilterType.__str__ = FilterType.__repr__ diff --git a/python/pylibcudf/pylibcudf/strings/wrap.pxd b/python/pylibcudf/pylibcudf/strings/wrap.pxd index 62faaff36f0..ea74927498d 100644 --- a/python/pylibcudf/pylibcudf/strings/wrap.pxd +++ b/python/pylibcudf/pylibcudf/strings/wrap.pxd @@ -1,12 +1,11 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from pylibcudf.column cimport Column from pylibcudf.libcudf.types cimport size_type from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -from rmm.pylibrmm.stream cimport Stream cpdef Column wrap( - Column input, size_type width, Stream stream=*, DeviceMemoryResource mr=* + Column input, size_type width, object stream = *, DeviceMemoryResource mr=* ) diff --git a/python/pylibcudf/pylibcudf/strings/wrap.pyi b/python/pylibcudf/pylibcudf/strings/wrap.pyi index 00c939cc420..aa88b64a391 100644 --- a/python/pylibcudf/pylibcudf/strings/wrap.pyi +++ b/python/pylibcudf/pylibcudf/strings/wrap.pyi @@ -1,14 +1,14 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column +from pylibcudf.utils import CudaStreamLike def wrap( input: Column, width: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/wrap.pyx b/python/pylibcudf/pylibcudf/strings/wrap.pyx index 504c469debc..28bc310b5a4 100644 --- a/python/pylibcudf/pylibcudf/strings/wrap.pyx +++ b/python/pylibcudf/pylibcudf/strings/wrap.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr @@ -10,11 +10,12 @@ from pylibcudf.libcudf.types cimport size_type from pylibcudf.utils cimport _get_stream, _get_memory_resource from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from rmm.pylibrmm.stream cimport Stream +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["wrap"] cpdef Column wrap( - Column input, size_type width, Stream stream=None, DeviceMemoryResource mr=None + Column input, size_type width, object stream=None, DeviceMemoryResource mr=None ): """ Wraps strings onto multiple lines shorter than `width` by @@ -41,15 +42,16 @@ cpdef Column wrap( Column of wrapped strings """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_wrap.wrap( input.view(), width, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) diff --git a/python/pylibcudf/pylibcudf/table.pxd b/python/pylibcudf/pylibcudf/table.pxd index 4a4a963e0de..76c38dacf3f 100644 --- a/python/pylibcudf/pylibcudf/table.pxd +++ b/python/pylibcudf/pylibcudf/table.pxd @@ -4,7 +4,6 @@ from libcpp.memory cimport unique_ptr from pylibcudf.libcudf.table.table cimport table from pylibcudf.libcudf.table.table_view cimport table_view -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource cdef class Table: @@ -20,7 +19,7 @@ cdef class Table: @staticmethod cdef Table from_libcudf( unique_ptr[table] libcudf_tbl, - Stream stream, + object stream, DeviceMemoryResource mr ) @@ -31,8 +30,8 @@ cdef class Table: cdef Table from_table_view_of_arbitrary( const table_view& tv, object owner, - Stream stream, + object stream, ) cpdef list columns(self) - cpdef Table copy(self, Stream stream=*, DeviceMemoryResource mr=*) + cpdef Table copy(self, object stream = *, DeviceMemoryResource mr=*) diff --git a/python/pylibcudf/pylibcudf/table.pyi b/python/pylibcudf/pylibcudf/table.pyi index 0f8de52b132..263bf813c75 100644 --- a/python/pylibcudf/pylibcudf/table.pyi +++ b/python/pylibcudf/pylibcudf/table.pyi @@ -4,11 +4,11 @@ from typing import Any from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf._interop_helpers import ArrowLike, ColumnMetadata from pylibcudf.column import Column from pylibcudf.types import DataType +from pylibcudf.utils import CudaStreamLike class Table: def __init__(self, column: list[Column]): ... @@ -18,22 +18,22 @@ class Table: def columns(self) -> list[Column]: ... def copy( self, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... def to_arrow( self, metadata: list[ColumnMetadata | str] | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, ) -> ArrowLike: ... # Private methods below are included because polars is currently using them, # but we want to remove stubs for these private methods eventually def _to_schema(self, metadata: Any = None) -> Any: ... - def _to_host_array(self, stream: Stream) -> Any: ... + def _to_host_array(self, stream: CudaStreamLike) -> Any: ... @staticmethod def from_arrow( arrow_like: ArrowLike, dtype: DataType | None = None, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... diff --git a/python/pylibcudf/pylibcudf/table.pyx b/python/pylibcudf/pylibcudf/table.pyx index 654cf9bb60b..6b62a5428f9 100644 --- a/python/pylibcudf/pylibcudf/table.pyx +++ b/python/pylibcudf/pylibcudf/table.pyx @@ -39,6 +39,7 @@ from pylibcudf._interop_helpers cimport ( _metadata_to_libcudf, ) from ._interop_helpers import ArrowLike, ColumnMetadata, _ObjectWithArrowMetadata +from cuda.bindings.cyruntime cimport cudaStream_t try: import pyarrow as pa @@ -105,7 +106,7 @@ cdef class Table: def from_arrow( obj: ArrowLike, dtype: DataType | None = None, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None ) -> Table: """ @@ -154,7 +155,8 @@ cdef class Table: cdef _ArrowTableHolder result cdef unique_ptr[arrow_table] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) if hasattr(obj, "__arrow_c_device_array__"): @@ -170,7 +172,7 @@ cdef class Table: c_result = make_unique[arrow_table]( move(dereference(c_schema)), move(dereference(c_array)), - stream.view(), + _cs, result.mr.get_mr(), ) result.tbl.swap(c_result) @@ -193,7 +195,7 @@ cdef class Table: with nogil: c_result = make_unique[arrow_table]( move(dereference(c_stream)), - stream.view(), + _cs, result.mr.get_mr(), ) result.tbl.swap(c_result) @@ -233,7 +235,7 @@ cdef class Table: @staticmethod cdef Table from_libcudf( unique_ptr[table] libcudf_tbl, - Stream stream, + object stream, DeviceMemoryResource mr ): """Create a Table from a libcudf table. @@ -275,7 +277,7 @@ cdef class Table: cdef Table from_table_view_of_arbitrary( const table_view& tv, object owner, - Stream stream, + object stream, ): """Create a Table from a libcudf table_view into an arbitrary owner. @@ -292,8 +294,9 @@ cdef class Table: # For efficiency, prohibit calling this overload with a Table owner. assert not isinstance(owner, Table) cdef int i + cdef Stream _stream = stream return Table([ - Column.from_column_view_of_arbitrary(tv.column(i), owner, stream) + Column.from_column_view_of_arbitrary(tv.column(i), owner, _stream) for i in range(tv.num_columns()) ]) @@ -315,7 +318,7 @@ cdef class Table: """The shape of this table""" return (self.num_rows(), self.num_columns()) - cpdef Table copy(self, Stream stream=None, DeviceMemoryResource mr=None): + cpdef Table copy(self, object stream=None, DeviceMemoryResource mr=None): """Create a deep copy of the table. Parameters @@ -330,9 +333,9 @@ cdef class Table: Table A new Table with deep copies of all columns. """ - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) mr = _get_memory_resource(mr) - return Table([col.copy(stream, mr) for col in self._columns]) + return Table([col.copy(_stream, mr) for col in self._columns]) def _to_schema(self, metadata=None): """Create an Arrow schema from this table.""" @@ -356,11 +359,13 @@ cdef class Table: return PyCapsule_New(raw_schema_ptr, "arrow_schema", _release_schema) - def _to_host_array(self, Stream stream): + def _to_host_array(self, object stream): cdef ArrowArray* raw_host_array_ptr + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() with nogil: - raw_host_array_ptr = to_arrow_host_raw(self.view(), stream.view()) + raw_host_array_ptr = to_arrow_host_raw(self.view(), _cs) return PyCapsule_New(raw_host_array_ptr, "arrow_array", _release_array) diff --git a/python/pylibcudf/pylibcudf/transform.pxd b/python/pylibcudf/pylibcudf/transform.pxd index a92ffb3f27e..8333abd6df0 100644 --- a/python/pylibcudf/pylibcudf/transform.pxd +++ b/python/pylibcudf/pylibcudf/transform.pxd @@ -3,7 +3,6 @@ from libcpp cimport bool from pylibcudf.libcudf.types cimport bitmask_type, data_type from pylibcudf.libcudf.types cimport null_aware, output_nullability -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from .column cimport Column @@ -14,30 +13,30 @@ from .types cimport DataType cpdef tuple[gpumemoryview, int] nans_to_nulls( - Column input, Stream stream = *, DeviceMemoryResource mr = * + Column input, object stream = *, DeviceMemoryResource mr = * ) cpdef Column column_nans_to_nulls( - Column input, Stream stream = *, DeviceMemoryResource mr = * + Column input, object stream = *, DeviceMemoryResource mr = * ) cpdef Column compute_column( - Table input, Expression expr, Stream stream = *, DeviceMemoryResource mr = * + Table input, Expression expr, object stream = *, DeviceMemoryResource mr = * ) cpdef Column compute_column_jit( - Table input, Expression expr, Stream stream = *, DeviceMemoryResource mr = * + Table input, Expression expr, object stream = *, DeviceMemoryResource mr = * ) cpdef tuple[gpumemoryview, int] bools_to_mask( - Column input, Stream stream = *, DeviceMemoryResource mr = * + Column input, object stream = *, DeviceMemoryResource mr = * ) cpdef Column mask_to_bools( Py_ssize_t bitmask, int begin_bit, int end_bit, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) @@ -48,17 +47,17 @@ cpdef Column transform( bool is_ptx, null_aware is_null_aware, output_nullability null_policy, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) cpdef tuple[Table, Column] encode( - Table input, Stream stream = *, DeviceMemoryResource mr = * + Table input, object stream = *, DeviceMemoryResource mr = * ) cpdef Table one_hot_encode( Column input_column, Column categories, - Stream stream = *, + object stream = *, DeviceMemoryResource mr = *, ) diff --git a/python/pylibcudf/pylibcudf/transform.pyi b/python/pylibcudf/pylibcudf/transform.pyi index 2d2038f07a0..e979575f590 100644 --- a/python/pylibcudf/pylibcudf/transform.pyi +++ b/python/pylibcudf/pylibcudf/transform.pyi @@ -1,46 +1,46 @@ # SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.expressions import Expression from pylibcudf.gpumemoryview import gpumemoryview from pylibcudf.table import Table from pylibcudf.types import DataType, NullAware, OutputNullability +from pylibcudf.utils import CudaStreamLike def nans_to_nulls( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[gpumemoryview, int]: ... def column_nans_to_nulls( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def compute_column( input: Table, expr: Expression, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def compute_column_jit( input: Table, expr: Expression, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def bools_to_mask( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[gpumemoryview, int]: ... def mask_to_bools( bitmask: int, begin_bit: int, end_bit: int, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def transform( @@ -50,17 +50,17 @@ def transform( is_ptx: bool, null_aware: NullAware = NullAware.NO, null_policy: OutputNullability = OutputNullability.PRESERVE, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def encode( input: Table, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> tuple[Table, Column]: ... def one_hot_encode( input: Column, categories: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... diff --git a/python/pylibcudf/pylibcudf/transform.pyx b/python/pylibcudf/pylibcudf/transform.pyx index 3baf6c5306e..0025ed7d566 100644 --- a/python/pylibcudf/pylibcudf/transform.pyx +++ b/python/pylibcudf/pylibcudf/transform.pyx @@ -26,6 +26,7 @@ from .expressions cimport Expression from .gpumemoryview cimport gpumemoryview from .types cimport DataType, null_aware, output_nullability from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "bools_to_mask", @@ -41,7 +42,7 @@ __all__ = [ cpdef tuple[gpumemoryview, int] nans_to_nulls( Column input, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Create a null mask preserving existing nulls and converting nans to null. @@ -63,21 +64,26 @@ cpdef tuple[gpumemoryview, int] nans_to_nulls( """ cdef pair[unique_ptr[device_buffer], size_type] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_transform.nans_to_nulls(input.view(), stream.view(), mr.get_mr()) + c_result = cpp_transform.nans_to_nulls( + input.view(), _cs, mr.get_mr() + ) return ( - gpumemoryview(DeviceBuffer.c_from_unique_ptr(move(c_result.first), stream, mr)), + gpumemoryview( + DeviceBuffer.c_from_unique_ptr(move(c_result.first), _stream, mr) + ), c_result.second ) cpdef Column column_nans_to_nulls( Column input, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Create a column with nans converted to nulls. @@ -100,19 +106,20 @@ cpdef Column column_nans_to_nulls( """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_transform.column_nans_to_nulls( - input.view(), stream.view(), mr.get_mr() + input.view(), _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column compute_column( - Table input, Expression expr, Stream stream=None, DeviceMemoryResource mr=None + Table input, Expression expr, object stream=None, DeviceMemoryResource mr=None ): """Create a column by evaluating an expression on a table. @@ -135,19 +142,20 @@ cpdef Column compute_column( """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_transform.compute_column( - input.view(), dereference(expr.c_obj.get()), stream.view(), mr.get_mr() + input.view(), dereference(expr.c_obj.get()), _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column compute_column_jit( - Table input, Expression expr, Stream stream=None, DeviceMemoryResource mr=None + Table input, Expression expr, object stream=None, DeviceMemoryResource mr=None ): """ Create a column by evaluating an expression on a table @@ -172,20 +180,21 @@ cpdef Column compute_column_jit( """ cdef unique_ptr[column] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_transform.compute_column_jit( - input.view(), dereference(expr.c_obj.get()), stream.view(), mr.get_mr() + input.view(), dereference(expr.c_obj.get()), _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef tuple[gpumemoryview, int] bools_to_mask( Column input, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Create a bitmask from a column of boolean elements @@ -206,14 +215,19 @@ cpdef tuple[gpumemoryview, int] bools_to_mask( """ cdef pair[unique_ptr[device_buffer], size_type] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_transform.bools_to_mask(input.view(), stream.view(), mr.get_mr()) + c_result = cpp_transform.bools_to_mask( + input.view(), _cs, mr.get_mr() + ) return ( - gpumemoryview(DeviceBuffer.c_from_unique_ptr(move(c_result.first), stream, mr)), + gpumemoryview( + DeviceBuffer.c_from_unique_ptr(move(c_result.first), _stream, mr) + ), c_result.second ) @@ -222,7 +236,7 @@ cpdef Column mask_to_bools( Py_ssize_t bitmask, int begin_bit, int end_bit, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Creates a boolean column from given bitmask. @@ -248,7 +262,8 @@ cpdef Column mask_to_bools( cdef unique_ptr[column] c_result cdef bitmask_type * bitmask_ptr = bitmask - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: @@ -256,11 +271,11 @@ cpdef Column mask_to_bools( bitmask_ptr, begin_bit, end_bit, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef Column transform( @@ -270,7 +285,7 @@ cpdef Column transform( bool is_ptx, null_aware is_null_aware, output_nullability null_policy, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Create a new column by applying a transform function against @@ -312,7 +327,8 @@ cpdef Column transform( cdef output_nullability c_null_policy = null_policy cdef optional[void *] user_data - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) for input in inputs: @@ -327,14 +343,14 @@ cpdef Column transform( user_data, c_is_null_aware, c_null_policy, - stream.view(), + _cs, mr.get_mr() ) - return Column.from_libcudf(move(c_result), stream, mr) + return Column.from_libcudf(move(c_result), _stream, mr) cpdef tuple[Table, Column] encode( - Table input, Stream stream=None, DeviceMemoryResource mr=None + Table input, object stream=None, DeviceMemoryResource mr=None ): """Encode the rows of the given table as integers. @@ -355,21 +371,22 @@ cpdef tuple[Table, Column] encode( """ cdef pair[unique_ptr[table], unique_ptr[column]] c_result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - c_result = cpp_transform.encode(input.view(), stream.view(), mr.get_mr()) + c_result = cpp_transform.encode(input.view(), _cs, mr.get_mr()) return ( - Table.from_libcudf(move(c_result.first), stream, mr), - Column.from_libcudf(move(c_result.second), stream, mr) + Table.from_libcudf(move(c_result.first), _stream, mr), + Column.from_libcudf(move(c_result.second), _stream, mr) ) cpdef Table one_hot_encode( Column input, Column categories, - Stream stream=None, + object stream=None, DeviceMemoryResource mr=None, ): """Encodes `input` by generating a new column @@ -395,19 +412,20 @@ cpdef Table one_hot_encode( cdef pair[unique_ptr[column], table_view] c_result cdef Table owner_table - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_transform.one_hot_encode( input.view(), categories.view(), - stream.view(), + _cs, mr.get_mr() ) owner_table = Table( - [Column.from_libcudf(move(c_result.first), stream, mr)] + [Column.from_libcudf(move(c_result.first), _stream, mr)] * c_result.second.num_columns() ) diff --git a/python/pylibcudf/pylibcudf/transpose.pxd b/python/pylibcudf/pylibcudf/transpose.pxd index 6c432a62b5f..a63d52da9e1 100644 --- a/python/pylibcudf/pylibcudf/transpose.pxd +++ b/python/pylibcudf/pylibcudf/transpose.pxd @@ -1,9 +1,8 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from .table cimport Table -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource -cpdef Table transpose(Table input_table, Stream stream=*, DeviceMemoryResource mr=*) +cpdef Table transpose(Table input_table, object stream = *, DeviceMemoryResource mr=*) diff --git a/python/pylibcudf/pylibcudf/transpose.pyi b/python/pylibcudf/pylibcudf/transpose.pyi index 4487e49feaf..fbf2d3fce2d 100644 --- a/python/pylibcudf/pylibcudf/transpose.pyi +++ b/python/pylibcudf/pylibcudf/transpose.pyi @@ -1,13 +1,13 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.table import Table +from pylibcudf.utils import CudaStreamLike def transpose( input_table: Table, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Table: ... diff --git a/python/pylibcudf/pylibcudf/transpose.pyx b/python/pylibcudf/pylibcudf/transpose.pyx index e7cdbe503eb..e15aa45ce77 100644 --- a/python/pylibcudf/pylibcudf/transpose.pyx +++ b/python/pylibcudf/pylibcudf/transpose.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.memory cimport unique_ptr from libcpp.pair cimport pair @@ -13,11 +13,12 @@ from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from .column cimport Column from .table cimport Table from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = ["transpose"] cpdef Table transpose( - Table input_table, Stream stream=None, DeviceMemoryResource mr=None + Table input_table, object stream=None, DeviceMemoryResource mr=None ): """Transpose a Table. @@ -39,16 +40,17 @@ cpdef Table transpose( """ cdef pair[unique_ptr[column], table_view] c_result cdef Table owner_table - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: c_result = cpp_transpose.transpose( - input_table.view(), stream.view(), mr.get_mr() + input_table.view(), _cs, mr.get_mr() ) owner_table = Table( - [Column.from_libcudf(move(c_result.first), stream, mr)] * + [Column.from_libcudf(move(c_result.first), _stream, mr)] * c_result.second.num_columns() ) diff --git a/python/pylibcudf/pylibcudf/unary.pxd b/python/pylibcudf/pylibcudf/unary.pxd index 69ec06ecea6..44a4f796085 100644 --- a/python/pylibcudf/pylibcudf/unary.pxd +++ b/python/pylibcudf/pylibcudf/unary.pxd @@ -1,9 +1,8 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp cimport bool from pylibcudf.libcudf.unary cimport unary_operator -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource from .column cimport Column @@ -11,19 +10,19 @@ from .types cimport DataType cpdef Column unary_operation( - Column input, unary_operator op, Stream stream = *, DeviceMemoryResource mr = * + Column input, unary_operator op, object stream = *, DeviceMemoryResource mr = * ) -cpdef Column is_null(Column input, Stream stream = *, DeviceMemoryResource mr = *) +cpdef Column is_null(Column input, object stream = *, DeviceMemoryResource mr = *) -cpdef Column is_valid(Column input, Stream stream = *, DeviceMemoryResource mr = *) +cpdef Column is_valid(Column input, object stream = *, DeviceMemoryResource mr = *) cpdef Column cast( - Column input, DataType data_type, Stream stream = *, DeviceMemoryResource mr = * + Column input, DataType data_type, object stream = *, DeviceMemoryResource mr = * ) -cpdef Column is_nan(Column input, Stream stream = *, DeviceMemoryResource mr = *) +cpdef Column is_nan(Column input, object stream = *, DeviceMemoryResource mr = *) -cpdef Column is_not_nan(Column input, Stream stream = *, DeviceMemoryResource mr = *) +cpdef Column is_not_nan(Column input, object stream = *, DeviceMemoryResource mr = *) cpdef bool is_supported_cast(DataType from_, DataType to) diff --git a/python/pylibcudf/pylibcudf/unary.pyi b/python/pylibcudf/pylibcudf/unary.pyi index 6a77f7998b9..dd3d42404e7 100644 --- a/python/pylibcudf/pylibcudf/unary.pyi +++ b/python/pylibcudf/pylibcudf/unary.pyi @@ -1,13 +1,13 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from enum import IntEnum from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from rmm.pylibrmm.stream import Stream from pylibcudf.column import Column from pylibcudf.types import DataType +from pylibcudf.utils import CudaStreamLike class UnaryOperator(IntEnum): SIN = ... @@ -38,33 +38,33 @@ class UnaryOperator(IntEnum): def unary_operation( input: Column, op: UnaryOperator, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def is_null( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def is_valid( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def cast( input: Column, data_type: DataType, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def is_nan( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def is_not_nan( input: Column, - stream: Stream | None = None, + stream: CudaStreamLike | None = None, mr: DeviceMemoryResource | None = None, ) -> Column: ... def is_supported_cast(from_: DataType, to: DataType) -> bool: ... diff --git a/python/pylibcudf/pylibcudf/unary.pyx b/python/pylibcudf/pylibcudf/unary.pyx index da5b08df685..e0614037012 100644 --- a/python/pylibcudf/pylibcudf/unary.pyx +++ b/python/pylibcudf/pylibcudf/unary.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp cimport bool @@ -16,6 +16,7 @@ from pylibcudf.libcudf.unary import \ from .column cimport Column from .types cimport DataType from .utils cimport _get_stream, _get_memory_resource +from cuda.bindings.cyruntime cimport cudaStream_t __all__ = [ "UnaryOperator", @@ -29,7 +30,7 @@ __all__ = [ ] cpdef Column unary_operation( - Column input, unary_operator op, Stream stream=None, DeviceMemoryResource mr=None + Column input, unary_operator op, object stream=None, DeviceMemoryResource mr=None ): """Perform a unary operation on a column. @@ -53,16 +54,19 @@ cpdef Column unary_operation( """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - result = cpp_unary.unary_operation(input.view(), op, stream.view(), mr.get_mr()) + result = cpp_unary.unary_operation( + input.view(), op, _cs, mr.get_mr() + ) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) -cpdef Column is_null(Column input, Stream stream=None, DeviceMemoryResource mr=None): +cpdef Column is_null(Column input, object stream=None, DeviceMemoryResource mr=None): """Check whether elements of a column are null. For details, see :cpp:func:`is_null`. @@ -83,16 +87,17 @@ cpdef Column is_null(Column input, Stream stream=None, DeviceMemoryResource mr=N """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - result = cpp_unary.is_null(input.view(), stream.view(), mr.get_mr()) + result = cpp_unary.is_null(input.view(), _cs, mr.get_mr()) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) -cpdef Column is_valid(Column input, Stream stream=None, DeviceMemoryResource mr=None): +cpdef Column is_valid(Column input, object stream=None, DeviceMemoryResource mr=None): """Check whether elements of a column are valid. For details, see :cpp:func:`is_valid`. @@ -113,17 +118,18 @@ cpdef Column is_valid(Column input, Stream stream=None, DeviceMemoryResource mr= """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - result = cpp_unary.is_valid(input.view(), stream.view(), mr.get_mr()) + result = cpp_unary.is_valid(input.view(), _cs, mr.get_mr()) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef Column cast( - Column input, DataType data_type, Stream stream=None, DeviceMemoryResource mr=None + Column input, DataType data_type, object stream=None, DeviceMemoryResource mr=None ): """Cast a column to a different data type. @@ -147,18 +153,19 @@ cpdef Column cast( """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: result = cpp_unary.cast( - input.view(), data_type.c_obj, stream.view(), mr.get_mr() + input.view(), data_type.c_obj, _cs, mr.get_mr() ) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) -cpdef Column is_nan(Column input, Stream stream=None, DeviceMemoryResource mr=None): +cpdef Column is_nan(Column input, object stream=None, DeviceMemoryResource mr=None): """Check whether elements of a column are nan. For details, see :cpp:func:`is_nan`. @@ -179,16 +186,17 @@ cpdef Column is_nan(Column input, Stream stream=None, DeviceMemoryResource mr=No """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - result = cpp_unary.is_nan(input.view(), stream.view(), mr.get_mr()) + result = cpp_unary.is_nan(input.view(), _cs, mr.get_mr()) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) -cpdef Column is_not_nan(Column input, Stream stream=None, DeviceMemoryResource mr=None): +cpdef Column is_not_nan(Column input, object stream=None, DeviceMemoryResource mr=None): """Check whether elements of a column are not nan. For details, see :cpp:func:`is_not_nan`. @@ -209,13 +217,14 @@ cpdef Column is_not_nan(Column input, Stream stream=None, DeviceMemoryResource m """ cdef unique_ptr[column] result - stream = _get_stream(stream) + cdef Stream _stream = _get_stream(stream) + cdef cudaStream_t _cs = _stream.view().value() mr = _get_memory_resource(mr) with nogil: - result = cpp_unary.is_not_nan(input.view(), stream.view(), mr.get_mr()) + result = cpp_unary.is_not_nan(input.view(), _cs, mr.get_mr()) - return Column.from_libcudf(move(result), stream, mr) + return Column.from_libcudf(move(result), _stream, mr) cpdef bool is_supported_cast(DataType from_, DataType to): """Check if a cast between datatypes is supported. diff --git a/python/pylibcudf/pylibcudf/utils.pxd b/python/pylibcudf/pylibcudf/utils.pxd index b3d2928f398..feb82cea18f 100644 --- a/python/pylibcudf/pylibcudf/utils.pxd +++ b/python/pylibcudf/pylibcudf/utils.pxd @@ -1,12 +1,12 @@ -# SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 from libcpp.functional cimport reference_wrapper from libcpp.vector cimport vector from pylibcudf.libcudf.scalar.scalar cimport scalar -from rmm.pylibrmm.stream cimport Stream from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource +from rmm.pylibrmm.stream cimport Stream cdef vector[reference_wrapper[const scalar]] _as_vector(list source) -cpdef Stream _get_stream(Stream stream = *) +cpdef Stream _get_stream(object stream = *) cdef DeviceMemoryResource _get_memory_resource(DeviceMemoryResource mr = *) diff --git a/python/pylibcudf/pylibcudf/utils.pyi b/python/pylibcudf/pylibcudf/utils.pyi index 21f669898ba..cc3cb93e6c0 100644 --- a/python/pylibcudf/pylibcudf/utils.pyi +++ b/python/pylibcudf/pylibcudf/utils.pyi @@ -1,6 +1,13 @@ # SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 +from typing import Protocol + from rmm.pylibrmm.stream import Stream -def _get_stream(stream: Stream | None = None) -> Stream: ... +class HasCudaStream(Protocol): + def __cuda_stream__(self) -> tuple[int, int]: ... + +CudaStreamLike = Stream | HasCudaStream + +def _get_stream(stream: CudaStreamLike | None = None) -> Stream: ... diff --git a/python/pylibcudf/pylibcudf/utils.pyx b/python/pylibcudf/pylibcudf/utils.pyx index 70460e19481..314e62f7760 100644 --- a/python/pylibcudf/pylibcudf/utils.pyx +++ b/python/pylibcudf/pylibcudf/utils.pyx @@ -47,10 +47,12 @@ cdef vector[reference_wrapper[const scalar]] _as_vector(list source): return c_scalars -cpdef Stream _get_stream(Stream stream = None): +cpdef Stream _get_stream(object stream = None): if stream is None: return CUDF_DEFAULT_STREAM - return stream + if isinstance(stream, Stream): + return stream + return Stream(stream) # Handles __cuda_stream__ protocol cdef DeviceMemoryResource _get_memory_resource(DeviceMemoryResource mr = None): diff --git a/python/pylibcudf/tests/test_experimental.py b/python/pylibcudf/tests/test_experimental.py index eaf06ff62ae..ed180e8db29 100644 --- a/python/pylibcudf/tests/test_experimental.py +++ b/python/pylibcudf/tests/test_experimental.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 import pytest @@ -21,6 +21,7 @@ def test_join_streams(streams: list[Stream], stream: Stream): plc.experimental.join_streams(streams, stream) +@pytest.mark.uses_custom_stream def test_join_streams_type_error(): """Test that join_streams raises appropriate errors for invalid inputs.""" main_stream = Stream() @@ -29,16 +30,10 @@ def test_join_streams_type_error(): with pytest.raises(TypeError): plc.experimental.join_streams(None, main_stream) - # Test with non-Stream in list - with pytest.raises( - TypeError, - match="Cannot convert NoneType to rmm.pylibrmm.stream.Stream", - ): - plc.experimental.join_streams([None], main_stream) - - # Test with non-Stream as main stream - with pytest.raises( - TypeError, - match="Cannot convert NoneType to rmm.pylibrmm.stream.Stream", - ): - plc.experimental.join_streams([Stream()], None) + # Protocol stream should be accepted + class _CudaStreamProto: + def __cuda_stream__(self): + return (0, 0) + + plc.experimental.join_streams([_CudaStreamProto()], main_stream) + plc.experimental.join_streams([Stream()], _CudaStreamProto()) diff --git a/python/pylibcudf/tests/test_stream_protocol.py b/python/pylibcudf/tests/test_stream_protocol.py new file mode 100644 index 00000000000..075c49bd0b3 --- /dev/null +++ b/python/pylibcudf/tests/test_stream_protocol.py @@ -0,0 +1,74 @@ +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. +# SPDX-License-Identifier: Apache-2.0 + +import pyarrow as pa +import pytest + +from rmm.pylibrmm.stream import Stream + +import pylibcudf as plc + + +class _CudaStreamProto: + """Minimal __cuda_stream__ protocol object for testing.""" + + def __cuda_stream__(self): + return (0, 0) + + +def test_get_stream_none(): + stream = plc.utils._get_stream(None) + assert isinstance(stream, Stream) + + +def test_get_stream_stream_object(): + stream = Stream() + result = plc.utils._get_stream(stream) + assert result is stream + + +def test_get_stream_protocol_object(): + proto = _CudaStreamProto() + result = plc.utils._get_stream(proto) + assert isinstance(result, Stream) + + +@pytest.mark.parametrize("stream", [None, Stream(), _CudaStreamProto()]) +def test_reduce_accepts_stream_protocol(stream): + arr = pa.array([1, 2, 3], type=pa.int32()) + col = plc.Column.from_arrow(arr) + agg = plc.aggregation.sum() + dtype = plc.DataType.from_arrow(pa.int32()) + result = plc.reduce.reduce(col, agg, dtype, stream=stream) + assert result.to_py() == 6 + + +@pytest.mark.parametrize("stream", [None, Stream(), _CudaStreamProto()]) +def test_binary_operation_accepts_stream_protocol(stream): + lhs = plc.Column.from_arrow(pa.array([1, 2, 3], type=pa.int32())) + rhs = plc.Column.from_arrow(pa.array([4, 5, 6], type=pa.int32())) + dtype = plc.DataType.from_arrow(pa.int32()) + result = plc.binaryop.binary_operation( + lhs, + rhs, + plc.binaryop.BinaryOperator.ADD, + dtype, + stream=stream, + ) + expect = pa.array([5, 7, 9], type=pa.int32()) + assert result.to_arrow().equals(expect) + + +@pytest.mark.parametrize("stream", [None, Stream(), _CudaStreamProto()]) +def test_gather_accepts_stream_protocol(stream): + table = plc.Table.from_arrow(pa.table({"a": [1, 2, 3], "b": [4, 5, 6]})) + indices = plc.Column.from_arrow(pa.array([2, 0], type=pa.int32())) + result = plc.copying.gather( + table, + indices, + plc.copying.OutOfBoundsPolicy.DONT_CHECK, + stream=stream, + ) + expected = pa.table({"a": [3, 1], "b": [6, 4]}) + got = result.to_arrow().rename_columns(expected.column_names) + assert got.cast(expected.schema).equals(expected)