Skip to content

dpnp.power() doesn't work properly with a scalar #1323

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 4 commits into from
Mar 3, 2023

Conversation

antonwolfy
Copy link
Contributor

@antonwolfy antonwolfy commented Mar 1, 2023

Since the change implemented in #1201 and until now, implicit operation ** of array with a scalar or explicit one through dpnp.power leads to raising of the not-implemented exception in dpnp. This is because dpnp was falling back on NumPy implementation in that use case, but has to call an internal kernel function from the backend.

The PR proposes to copy a scalar data from host memory into USM allocated memory, which means to create zero-dimension dpnp array from the scalar. This way the power of array with a scalar or the power of scalar with an array will be handled in the same way as power with two arrays, which already works fine in dpnp.

Note that if some input argument is a scalar and another one is an array, memory for the scalar will be allocated on the same SYCL device and with the same USM type as the array has. It's required to proceed with further computing and to be compliant with compute follows data paradigm (all input data has to reside on the same device).

  • 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?

Copy link
Contributor

@oleksandr-pavlyk oleksandr-pavlyk left a comment

Choose a reason for hiding this comment

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

LGTM from skimming through the code.

@antonwolfy antonwolfy merged commit 4b9a5cd into IntelPython:master Mar 3, 2023
@antonwolfy antonwolfy deleted the pow_by_scalar branch March 3, 2023 13:40
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.

3 participants