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

Reduce memory usage of as_categorical_column #14138

Merged
Merged
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
17 changes: 8 additions & 9 deletions python/cudf/cudf/core/column/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,20 +1390,19 @@ def _return_sentinel_column():
except ValueError:
return _return_sentinel_column()

codes = arange(len(cats), dtype=dtype)
left_gather_map, right_gather_map = cpp_join(
[self], [cats], how="left"
)
codes = codes.take(
right_gather_map, nullify=True, check_bounds=False
).fillna(na_sentinel.value)

codes = libcudf.copying.gather(
[arange(len(cats), dtype=dtype)], right_gather_map, nullify=True
)
del right_gather_map
# reorder `codes` so that its values correspond to the
# values of `self`:
order = arange(len(self))
order = order.take(left_gather_map, check_bounds=False).argsort()
codes = codes.take(order)
return codes
(codes,) = libcudf.sort.sort_by_key(
codes, [left_gather_map], [True], ["last"], stable=True
)
return codes.fillna(na_sentinel.value)


def column_empty_like(
Expand Down
Loading