Skip to content

Support upper and lower in strings_udf - #12099

Merged
rapids-bot[bot] merged 84 commits into
NVIDIA:branch-22.12from
brandon-b-miller:fea-stringudf-upper-lower
Nov 17, 2022
Merged

Support upper and lower in strings_udf#12099
rapids-bot[bot] merged 84 commits into
NVIDIA:branch-22.12from
brandon-b-miller:fea-stringudf-upper-lower

Conversation

@brandon-b-miller

Copy link
Copy Markdown
Contributor

This PR adds support for the following two functions in strings_udf:

  • str.upper()
  • str.lower()

Part of #9639

@codecov

codecov Bot commented Nov 14, 2022

Copy link
Copy Markdown

Codecov Report

Base: 87.47% // Head: 88.24% // Increases project coverage by +0.77% 🎉

Coverage data is based on head (f85ac6d) compared to base (f817d96).
Patch has no changes to coverable lines.

Additional details and impacted files
@@               Coverage Diff                @@
##           branch-22.12   #12099      +/-   ##
================================================
+ Coverage         87.47%   88.24%   +0.77%     
================================================
  Files               133      137       +4     
  Lines             21826    22553     +727     
================================================
+ Hits              19093    19903     +810     
+ Misses             2733     2650      -83     
Impacted Files Coverage Δ
python/cudf/cudf/core/column/interval.py 85.45% <0.00%> (-9.10%) ⬇️
python/cudf/cudf/io/text.py 91.66% <0.00%> (-8.34%) ⬇️
python/cudf/cudf/core/_base_index.py 81.28% <0.00%> (-4.27%) ⬇️
python/cudf/cudf/io/json.py 92.06% <0.00%> (-2.68%) ⬇️
python/cudf/cudf/utils/utils.py 89.91% <0.00%> (-0.69%) ⬇️
python/cudf/cudf/core/column/timedelta.py 90.17% <0.00%> (-0.58%) ⬇️
python/cudf/cudf/core/column/datetime.py 89.21% <0.00%> (-0.51%) ⬇️
python/cudf/cudf/core/column/column.py 87.96% <0.00%> (-0.46%) ⬇️
python/dask_cudf/dask_cudf/core.py 73.72% <0.00%> (-0.41%) ⬇️
python/cudf/cudf/io/parquet.py 90.45% <0.00%> (-0.39%) ⬇️
... and 46 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Comment on lines +278 to +280
std::int64_t flags_table,
std::int64_t cases_table,
std::int64_t special_table)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just curious why these are not void* as well?

@brandon-b-miller brandon-b-miller Nov 15, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Let me make sure all is right here. Each of the functions that return a pointer to an input mapping table returns its own type of pointer. For the flags table its uint8_t*, for the cases table its uint16_t. For the special case mapping table it's a special_case_mapping*. Would the correct thing to do in this case be to receive each of these as a uintptr_t in the cython and then carry them through the python into the lowering as a np.uintp? Then these shim functions could accept a uintptr_t here.

@davidwendt davidwendt Nov 15, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it would be more correct for these to be pointer types than int64_t types.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you can interact with ctypes I think you can carry around a ctypes.cvoidp.

@wence- wence- left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A bunch of nits around cross-calling ABI and type-punning pointers and integers.

Comment thread python/strings_udf/strings_udf/_lib/tables.pyx Outdated
Comment thread python/strings_udf/cpp/src/strings/udf/shim.cu Outdated

extern "C" __device__ int lower(int* nb_retval,
void* udf_str,
void* const* st,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this need to be a void ** or can it just be a void * (I note that inside you cast to string_view * and then dereference, so I think you can strip a * everywhere).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am not sure I follow here. This follows the pattern from the rest of the shim functions when a string_view is an arg. IIUC st is pointing directly to the struct, so only one level of pointing right?

@wence- wence- Nov 15, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Most functions here (e.g. https://github.com/rapidsai/cudf/blob/418cbc69b336f34b06e1de21ae2c016b40f1e6fc/python/strings_udf/cpp/src/strings/udf/shim.cu#L186-L193) that take a pointer to string_view take the argument as void const *, not void* const *. Why is this different?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ah you're right! updated this. Nice catch

Comment thread python/strings_udf/cpp/src/strings/udf/udf_apis.cu Outdated
Comment thread python/strings_udf/strings_udf/lowering.py Outdated
Comment thread python/strings_udf/cpp/src/strings/udf/shim.cu Outdated
Comment thread python/strings_udf/cpp/src/strings/udf/shim.cu
Comment thread python/strings_udf/strings_udf/lowering.py Outdated
@brandon-b-miller

Copy link
Copy Markdown
Contributor Author

rerun tests

@wence- wence- left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@davidwendt davidwendt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving C++ code.

@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 labels Nov 16, 2022
@brandon-b-miller

Copy link
Copy Markdown
Contributor Author

some test failures here that seem to be related to a previous PR that I am looking into now.

@brandon-b-miller

Copy link
Copy Markdown
Contributor Author

I am thinking these CI failures might be transient. Going to rerun tests just to make sure, as things seem to pass locally for me.

@brandon-b-miller

Copy link
Copy Markdown
Contributor Author

rerun tests

@brandon-b-miller

Copy link
Copy Markdown
Contributor Author

@gpucibot merge

@rapids-bot
rapids-bot Bot merged commit aa13b95 into NVIDIA:branch-22.12 Nov 17, 2022
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 numba Numba issue Python Affects Python cuDF API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants