dpnp.multiply() doesn't work properly with a scalar #1254
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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).