-
Notifications
You must be signed in to change notification settings - Fork 22
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
Implement asynchronous fill
method using dpctl
kernels
#2055
base: master
Are you sure you want to change the base?
Implement asynchronous fill
method using dpctl
kernels
#2055
Conversation
fill
method using dpctl
kernelsfill
method using dpctl
kernels
Leverages dpctl's strided fill and memset for setting contiguous memory to 0
7e3662b
to
b8dad1e
Compare
New fill implementation does not permit NumPy array values, consistent with fill_diagonal
@antonwolfy @vtavana @vlad-perevezentsev
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ndgrigorian, thank you for implementing so great improvement.
Please find some comments below.
@@ -903,8 +903,10 @@ def fill(self, value): | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please update docstring a bit, like:
"""
Fill the array with a scalar value.
For full documentation refer to :obj:`numpy.ndarray.fill`.
Parameters
----------
value : {dpnp.ndarray, usm_ndarray, scalar}
All elements of `a` will be assigned this value.
Examples
--------
>>> import numpy as np
>>> a = np.array([1, 2])
>>> a.fill(0)
>>> a
array([0, 0])
>>> a = np.empty(2)
>>> a.fill(1)
>>> a
array([1., 1.])
"""
if isinstance(val, (dpnp_array, dpt.usm_ndarray)): | ||
val = dpnp.get_usm_ndarray(val) | ||
if val.shape != (): | ||
raise ValueError("`val` must be a scalar") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add tests to cover lines: 50, 71, 73?
Instead now accepts `ValueError` and `TypeError` in addition to `ComplexWarning`
ef96194
to
151b6a9
Compare
This PR proposes a change to
dpnp_array.fill
method which leverages dpctl kernels to makefill
asynchronous and more efficient, avoiding repeated calls to index the array and copying scalars to the device for each element.Shows significant performance gains on Iris Xe in WSL
Before
After