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

Add missing meta kwarg to gufunc class #7423

Merged
merged 2 commits into from Mar 26, 2021
Merged

Conversation

pentschev
Copy link
Member

@pentschev
Copy link
Member Author

Reposting #7384 (comment) here to provide a brief explanation on what this PR is attempting to resolve:

TBH, I'm not very skilled with gufuncs. However, I spent some (too much) time trying to understand what's going on here, I can confirm changes from #6736 are indeed responsible for this. The problem lies on those divergences between how libraries treat scalars, 0D and ND arrays, and I'm fairly certain this is to some extent very similar to the problem discussed in #6690 .

Right now, I don't have an optimal solution to offer, but a perhaps decently acceptable solution is to specify meta= in as_gufunc, as has been the trend for such corner cases that are really difficult to get working right among all different libraries. I opened #7423 to attempt providing a solution for this, but unfortunately I don't have the bandwidth now dig deeper on a solution that wouldn't require meta=.

@pentschev
Copy link
Member Author

cc @TAdeJong @jsignell

Copy link
Member

@jsignell jsignell left a comment

Choose a reason for hiding this comment

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

Thank you for writing this up @pentschev and sorry I didn't review it sooner. It seems to me that this is a clear improvement and if we want to finesse how other kwargs are handled in the future we can reasonably do that as well. Having the meta as a kwarg is a good escape hatch.

@jsignell jsignell merged commit c9829b3 into dask:main Mar 26, 2021
@@ -560,6 +560,9 @@ class gufunc:
dimensions are to consist only of one chunk.
Warning: enabling this can increase memory usage significantly.
Defaults to ``False``.
meta: Optional, tuple, keyword only
tuple of empty ndarrays describing the shape and dtype of the output of the gufunc.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
tuple of empty ndarrays describing the shape and dtype of the output of the gufunc.
tuple of empty ndarrays describing the type of array and dtype of the output of the gufunc.

@@ -602,6 +616,7 @@ def __init__(self, pyfunc, **kwargs):
self.output_sizes = kwargs.pop("output_sizes", None)
self.output_dtypes = kwargs.pop("output_dtypes", None)
self.allow_rechunk = kwargs.pop("allow_rechunk", False)
self.meta = kwargs.pop("meta", None)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we check, and throw a warning in case of, mismatch between output_dtypes and the dtypes as given in meta?

@TAdeJong
Copy link
Contributor

TAdeJong commented Mar 26, 2021

@jsignell Oops, I had still noticed two small improvements to this PR... Sorry, for not giving input sooner, had other stuff on my plate. Just too late I guess.

@jsignell
Copy link
Member

No worries, you are welcome to open another PR with these changes if you like :)

@pentschev pentschev deleted the fix-gufunc-meta branch June 30, 2021 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants