-
Notifications
You must be signed in to change notification settings - Fork 915
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
Migrate expressions to pylibcudf #16056
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c256f1e
Migrate expressions to pylibcudf
lithomas1 a57b132
fix typo in docs
lithomas1 5bc6917
Merge branch 'branch-24.08' of github.com:rapidsai/cudf into pylibcud…
lithomas1 7c0d72d
add to init file
lithomas1 04213d1
Merge branch 'branch-24.08' of github.com:rapidsai/cudf into pylibcud…
lithomas1 2bc2fb8
Merge branch 'branch-24.08' of github.com:rapidsai/cudf into pylibcud…
lithomas1 0210fd2
sync parquet changes
lithomas1 6f3ae30
Merge branch 'branch-24.08' of github.com:rapidsai/cudf into pylibcud…
lithomas1 649454c
take in scalars instead
lithomas1 a6f305b
Apply suggestions from code review
lithomas1 2590f6e
Merge branch 'branch-24.08' into pylibcudf-expr
lithomas1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,6 +1,6 @@ | ||
======= | ||
copying | ||
======= | ||
======== | ||
datetime | ||
======== | ||
|
||
.. automodule:: cudf._lib.pylibcudf.datetime | ||
:members: |
6 changes: 6 additions & 0 deletions
6
docs/cudf/source/user_guide/api_docs/pylibcudf/expressions.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 @@ | ||
=========== | ||
expressions | ||
=========== | ||
|
||
.. automodule:: cudf._lib.pylibcudf.expressions | ||
: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
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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ from . cimport ( | |
concatenate, | ||
copying, | ||
datetime, | ||
expressions, | ||
filling, | ||
groupby, | ||
join, | ||
|
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
concatenate, | ||
copying, | ||
datetime, | ||
expressions, | ||
filling, | ||
groupby, | ||
interop, | ||
|
29 changes: 12 additions & 17 deletions
29
python/cudf/cudf/_lib/expressions.pxd → .../cudf/cudf/_lib/pylibcudf/expressions.pxd
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,36 +1,31 @@ | ||
# Copyright (c) 2022-2024, NVIDIA CORPORATION. | ||
|
||
from libc.stdint cimport int32_t, int64_t | ||
# Copyright (c) 2024, NVIDIA CORPORATION. | ||
from libcpp.memory cimport unique_ptr | ||
from libcpp.string cimport string | ||
|
||
from cudf._lib.pylibcudf.libcudf.expressions cimport ( | ||
column_reference, | ||
ast_operator, | ||
expression, | ||
literal, | ||
operation, | ||
) | ||
from cudf._lib.pylibcudf.libcudf.scalar.scalar cimport ( | ||
numeric_scalar, | ||
scalar, | ||
string_scalar, | ||
timestamp_scalar, | ||
table_reference, | ||
) | ||
|
||
from .scalar cimport Scalar | ||
|
||
|
||
cdef class Expression: | ||
cdef unique_ptr[expression] c_obj | ||
|
||
|
||
cdef class Literal(Expression): | ||
cdef unique_ptr[scalar] c_scalar | ||
|
||
# Hold on to input scalar so it doesn't get gc'ed | ||
cdef Scalar scalar | ||
|
||
cdef class ColumnReference(Expression): | ||
pass | ||
|
||
|
||
cdef class Operation(Expression): | ||
pass | ||
# Hold on to the input expressions so | ||
# they don't get gc'ed | ||
cdef Expression right | ||
cdef Expression left | ||
|
||
cdef class ColumnNameReference(Expression): | ||
pass |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a use-after-free here (in the old cudf/_lib/expressions.pyx) previously, but it didn't get caught I think because the inputs to Operations weren't gc'ed yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, if the C++ side takes a reference, we need to hold on to the object on the Python side, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup we do, that's a good catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous approach was "person constructing the expression must keep everything alive".