Skip to content

Raise not-implemented exception on numpy fallback #1201

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

Merged
merged 8 commits into from
Nov 16, 2022

Conversation

antonwolfy
Copy link
Contributor

@antonwolfy antonwolfy commented Oct 17, 2022

Previously DPNP fell back on NumPy implementation when a requested functionality isn't available and can't be provided by DPNP.
The PR is indented to raise Non-implemented exception in that scenario by default, rather than falling back.

It will be possible to keep old behavior with falling back on NumPy calls by setting a new environment variable DPNP_RAISE_EXCEPION_ON_NUMPY_FALLBACK = 0.
In all other cases, the fallback is prohibited and lead to the exception.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • If this PR is a work in progress, are you filing the PR as a draft?

@antonwolfy antonwolfy self-assigned this Oct 17, 2022
@antonwolfy antonwolfy added the in progress Please do not merge. Work is in progress. label Oct 17, 2022
@oleksandr-pavlyk
Copy link
Contributor

Implementation in this PR falls back by default, allows opting out. I should clarify, but I thought we agreed to raises by default, permits opt-in.

@oleksandr-pavlyk
Copy link
Contributor

Implementation in this PR falls back by default, allows opting out. I should clarify, but I thought we agreed to raises by default, permits opt-in.

Never mind I misread the code, it works as expected

@antonwolfy antonwolfy removed the in progress Please do not merge. Work is in progress. label Nov 14, 2022
@antonwolfy antonwolfy force-pushed the exception_on_numpy_fallback branch from 9f67cf8 to 001fb25 Compare November 14, 2022 21:22
raise OverflowError(f"Range of loc={loc} exceeds valid bounds")

if (scale >= max_double) and dpnp.isfinite(scale):
if (scale >= max_double) and numpy.isfinite(scale):
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps factor out uses of numpy.isfinite into your own routine which can be modified as needed.

If scale always remains a Python or NumPy scalar, than not compute-follows-data violation occurs, but if scale can be an array, then your modular routine can be modified to apply appropriate validation function.

Copy link
Contributor Author

@antonwolfy antonwolfy Nov 15, 2022

Choose a reason for hiding this comment

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

Added internal functions _is_finite_scalar() and _is_finite_scalar() to dpnp_random_state.py with TODO comment inside to replace with dpnp functionality once availbale.

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