Skip to content

dpnp.multiply() doesn't work properly with a scalar #1254

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 7 commits into from
Dec 21, 2022

Conversation

antonwolfy
Copy link
Contributor

@antonwolfy antonwolfy commented Dec 12, 2022

Since the change implemented in #1201 and until now, implicit multiplication of array with a scalar or explicit one through dpnp.multiply call 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 issue was reported in #1238.

The PR proposes to copy a scalar data from host memory into device allocated memory, which means to create zero-dimension dpnp array from the scalar. This way the multiplication of array with a scalar will be handled in the same way as multiplication of 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 where the array resides on. 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?

@antonwolfy antonwolfy self-assigned this Dec 12, 2022
@antonwolfy antonwolfy merged commit d5ccdfd into IntelPython:master Dec 21, 2022
@antonwolfy antonwolfy deleted the multiply_by_scalar branch December 21, 2022 19: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.

2 participants