-
Notifications
You must be signed in to change notification settings - Fork 933
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement concatenate, lists.explode, merge, sorting, and stream comp…
…action in pylibcudf (#15011) Contributes to #13921 Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Lawrence Mitchell (https://github.com/wence-) URL: #15011
- Loading branch information
Showing
34 changed files
with
1,121 additions
and
480 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
docs/cudf/source/user_guide/api_docs/pylibcudf/concatenate.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
=========== | ||
concatenate | ||
=========== | ||
|
||
.. automodule:: cudf._lib.pylibcudf.concatenate | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
===== | ||
lists | ||
===== | ||
|
||
.. automodule:: cudf._lib.pylibcudf.lists | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
===== | ||
merge | ||
===== | ||
|
||
.. automodule:: cudf._lib.pylibcudf.merge | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
======= | ||
sorting | ||
======= | ||
|
||
.. automodule:: cudf._lib.pylibcudf.sorting | ||
:members: |
6 changes: 6 additions & 0 deletions
6
docs/cudf/source/user_guide/api_docs/pylibcudf/stream_compaction.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
================= | ||
stream_compaction | ||
================= | ||
|
||
.. automodule:: cudf._lib.pylibcudf.stream_compaction | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,34 @@ | ||
# Copyright (c) 2020-2023, NVIDIA CORPORATION. | ||
# Copyright (c) 2020-2024, NVIDIA CORPORATION. | ||
|
||
from libcpp cimport bool | ||
from libcpp.memory cimport make_unique, unique_ptr | ||
from libcpp.utility cimport move | ||
from libcpp.vector cimport vector | ||
|
||
from cudf._lib.column cimport Column | ||
from cudf._lib.cpp.column.column cimport column, column_view | ||
from cudf._lib.cpp.concatenate cimport ( | ||
concatenate_columns as libcudf_concatenate_columns, | ||
concatenate_masks as libcudf_concatenate_masks, | ||
concatenate_tables as libcudf_concatenate_tables, | ||
) | ||
from cudf._lib.cpp.table.table cimport table, table_view | ||
from cudf._lib.utils cimport ( | ||
data_from_unique_ptr, | ||
make_column_views, | ||
table_view_from_table, | ||
) | ||
|
||
from cudf.core.buffer import acquire_spill_lock, as_buffer | ||
|
||
from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer | ||
|
||
|
||
cpdef concat_masks(object columns): | ||
cdef device_buffer c_result | ||
cdef unique_ptr[device_buffer] c_unique_result | ||
cdef vector[column_view] c_views = make_column_views(columns) | ||
with nogil: | ||
c_result = move(libcudf_concatenate_masks(c_views)) | ||
c_unique_result = move(make_unique[device_buffer](move(c_result))) | ||
return as_buffer( | ||
DeviceBuffer.c_from_unique_ptr(move(c_unique_result)) | ||
) | ||
from cudf._lib.utils cimport data_from_pylibcudf_table | ||
|
||
from cudf._lib import pylibcudf | ||
from cudf.core.buffer import acquire_spill_lock | ||
|
||
|
||
@acquire_spill_lock() | ||
def concat_columns(object columns): | ||
cdef unique_ptr[column] c_result | ||
cdef vector[column_view] c_views = make_column_views(columns) | ||
with nogil: | ||
c_result = move(libcudf_concatenate_columns(c_views)) | ||
return Column.from_unique_ptr(move(c_result)) | ||
return Column.from_pylibcudf( | ||
pylibcudf.concatenate.concatenate( | ||
[col.to_pylibcudf(mode="read") for col in columns] | ||
) | ||
) | ||
|
||
|
||
@acquire_spill_lock() | ||
def concat_tables(object tables, bool ignore_index=False): | ||
cdef unique_ptr[table] c_result | ||
cdef vector[table_view] c_views | ||
c_views.reserve(len(tables)) | ||
for tbl in tables: | ||
c_views.push_back(table_view_from_table(tbl, ignore_index)) | ||
with nogil: | ||
c_result = move(libcudf_concatenate_tables(c_views)) | ||
|
||
return data_from_unique_ptr( | ||
move(c_result), | ||
plc_tables = [] | ||
for table in tables: | ||
cols = table._data.columns | ||
if not ignore_index: | ||
cols = table._index._data.columns + cols | ||
plc_tables.append(pylibcudf.Table([c.to_pylibcudf(mode="read") for c in cols])) | ||
|
||
return data_from_pylibcudf_table( | ||
pylibcudf.concatenate.concatenate(plc_tables), | ||
column_names=tables[0]._column_names, | ||
index_names=None if ignore_index else tables[0]._index_names | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.