Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove cudf._lib.rolling in favor of inlining pylibcudf #17423

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion python/cudf/cudf/_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ set(cython_sources
reduce.pyx
replace.pyx
reshape.pyx
rolling.pyx
round.pyx
scalar.pyx
search.pyx
Expand Down
1 change: 0 additions & 1 deletion python/cudf/cudf/_lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
reduce,
replace,
reshape,
rolling,
round,
search,
sort,
Expand Down
67 changes: 0 additions & 67 deletions python/cudf/cudf/_lib/rolling.pyx

This file was deleted.

44 changes: 34 additions & 10 deletions python/cudf/cudf/core/window/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
import pandas as pd
from pandas.api.indexers import BaseIndexer

import pylibcudf as plc

import cudf
from cudf import _lib as libcudf
from cudf._lib.aggregation import make_aggregation
from cudf.api.types import is_integer, is_number
from cudf.core.buffer import acquire_spill_lock
from cudf.core.column.column import as_column
Expand Down Expand Up @@ -284,16 +287,37 @@ def _apply_agg_column(self, source_column, agg_name):
)
window = None

return libcudf.rolling.rolling(
source_column=source_column,
pre_column_window=preceding_window,
fwd_column_window=following_window,
window=window,
min_periods=min_periods,
center=self.center,
op=agg_name,
agg_params=self.agg_params,
)
with acquire_spill_lock():
if window is None:
if self.center:
# TODO: we can support this even though Pandas currently does not
raise NotImplementedError(
"center is not implemented for offset-based windows"
)
pre = preceding_window.to_pylibcudf(mode="read")
fwd = following_window.to_pylibcudf(mode="read")
else:
if self.center:
pre = (window // 2) + 1
fwd = window - (pre)
else:
pre = window
fwd = 0

return libcudf.column.Column.from_pylibcudf(
plc.rolling.rolling_window(
source_column.to_pylibcudf(mode="read"),
pre,
fwd,
min_periods,
make_aggregation(
agg_name,
{"dtype": source_column.dtype}
if callable(agg_name)
else self.agg_params,
).c_obj,
)
)

def _reduce(
self,
Expand Down
Loading