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

[REVIEW] Add handling of mixed numeric types in to_dlpack #9585

Merged
merged 6 commits into from
Nov 5, 2021

Conversation

galipremsagar
Copy link
Contributor

Resolves: #7123

This PR adds a common dtype casting as requested here: #7123 (comment)

@galipremsagar galipremsagar added feature request New feature or request Python Affects Python cuDF API. 4 - Needs cuDF (Python) Reviewer non-breaking Non-breaking change labels Nov 3, 2021
@galipremsagar galipremsagar self-assigned this Nov 3, 2021
@galipremsagar galipremsagar requested a review from a team as a code owner November 3, 2021 12:53
@galipremsagar
Copy link
Contributor Author

rerun tests

else:
raise TypeError(
f"Input of type {type(cudf_obj)} cannot be converted "
"to DLPack tensor"
)

return libdlpack.to_dlpack(gdf_cols)
if any(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's perhaps slightly more future proof to error based on a dtype not being present in a predefined supported set rather then checking if a dtype is in an unsupported set. That way you dont have to worry about updating it here as we add dtypes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, also I think we can be more direct here:

if any(not cudf.api.types.is_numeric(col.dtype) for col in gdf._data._columns)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to be more resilient with cudf.api.types._is_non_decimal_numeric_dtype.

@galipremsagar galipremsagar added 2 - In Progress Currently a work in progress and removed 4 - Needs cuDF (Python) Reviewer labels Nov 4, 2021
Copy link
Contributor

@isVoid isVoid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opinion: I think it's best to not include DataFrame etc. in dlpack.py. According to https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html, dependencies should go inward. to/from_dlpack are user facing functions that accepts any cudf object as input so IMO is outer most layer. This may also help alleviate the circular import issue you have with find_common_type.

@galipremsagar
Copy link
Contributor Author

rerun tests

@galipremsagar galipremsagar added the 5 - DO NOT MERGE Hold off on merging; see PR for details label Nov 4, 2021
@galipremsagar
Copy link
Contributor Author

did a run for cupy/ cuda 11.5 sake.

@codecov
Copy link

codecov bot commented Nov 4, 2021

Codecov Report

Merging #9585 (817cb59) into branch-21.12 (ab4bfaa) will decrease coverage by 0.14%.
The diff coverage is n/a.

❗ Current head 817cb59 differs from pull request most recent head fc89716. Consider uploading reports for the commit fc89716 to get more accurate results
Impacted file tree graph

@@               Coverage Diff                @@
##           branch-21.12    #9585      +/-   ##
================================================
- Coverage         10.79%   10.64%   -0.15%     
================================================
  Files               116      117       +1     
  Lines             18869    19344     +475     
================================================
+ Hits               2036     2059      +23     
- Misses            16833    17285     +452     
Impacted Files Coverage Δ
python/dask_cudf/dask_cudf/sorting.py 92.90% <0.00%> (-1.21%) ⬇️
python/cudf/cudf/io/csv.py 0.00% <0.00%> (ø)
python/cudf/cudf/io/orc.py 0.00% <0.00%> (ø)
python/cudf/cudf/__init__.py 0.00% <0.00%> (ø)
python/cudf/cudf/io/dlpack.py 0.00% <0.00%> (ø)
python/cudf/cudf/core/frame.py 0.00% <0.00%> (ø)
python/cudf/cudf/core/index.py 0.00% <0.00%> (ø)
python/cudf/cudf/io/parquet.py 0.00% <0.00%> (ø)
python/cudf/cudf/core/series.py 0.00% <0.00%> (ø)
python/cudf/cudf/core/reshape.py 0.00% <0.00%> (ø)
... and 43 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9fa6ec0...fc89716. Read the comment docs.

@galipremsagar galipremsagar added 3 - Ready for Review Ready for review by team 4 - Needs cuDF (Python) Reviewer and removed 2 - In Progress Currently a work in progress 5 - DO NOT MERGE Hold off on merging; see PR for details labels Nov 5, 2021
@galipremsagar galipremsagar added 5 - Ready to Merge Testing and reviews complete, ready to merge and removed 3 - Ready for Review Ready for review by team 4 - Needs cuDF (Python) Reviewer labels Nov 5, 2021
@galipremsagar
Copy link
Contributor Author

@gpucibot merge

@rapids-bot rapids-bot bot merged commit 52f2619 into rapidsai:branch-21.12 Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 - Ready to Merge Testing and reviews complete, ready to merge feature request New feature or request non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEA] Remove "All columns required to have same data type" requirement in .to_dlpack() method.
3 participants