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

Fallback to self = np.ndarray when necessary #431

Merged

Conversation

bryevdv
Copy link
Contributor

@bryevdv bryevdv commented Jun 28, 2022

This PR renames the clone_class decorator to clone_np_ndarray to reflect the fact that it is closely tied to the implementation of np.ndarray.

Additionally, this PR fixes the issue reported by @fduguet-nv

>>> import cunumeric as num
>>> ones = num.ones((10,))
>>> ones.mean()
array(1.)
>>> ones.std()
<console>:1: RuntimeWarning: cuNumeric has not implemented numpy.ndarray.std and is falling back to canonical numpy. You may notice significantly decreased performance for this function call.
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/fduguet/github/cunumeric-fduguet/cunumeric/coverage.py", line 165, in wrapper
    return func(*args, **kwargs)
TypeError: descriptor 'std' for 'numpy.ndarray' objects doesn't apply to a 'ndarray' object

A fix similar to #430 was added, which is tested in a new integration test. The fix is slightly more general, which would allow for any future specific clone_xyz class decorators to also make use of it. This PR supersedes #430.

@bryevdv bryevdv requested a review from manopapad June 28, 2022 20:12
# to verify a behaviour of unimplemented ndarray method wrappers. If std
# becomes implemeneted in the future, this assertion will start to fail,
# and a new (unimplemented) ndarray method should be found to replace it
assert not ones.std._cunumeric.implemented
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@magnatelee I don't love this but I am not sure what else we can really do.

@bryevdv bryevdv merged commit 755f3f7 into nv-legate:branch-22.07 Jul 18, 2022
@bryevdv bryevdv deleted the bryanv/unimplemented_self_fallback branch July 18, 2022 17:48
jjwilke pushed a commit to jjwilke/cunumeric that referenced this pull request Jul 29, 2022
jjwilke pushed a commit to jjwilke/cunumeric that referenced this pull request Jul 29, 2022
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.

2 participants