-
Notifications
You must be signed in to change notification settings - Fork 30
Add dparray #192
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
Add dparray #192
Conversation
Fixed comments @oleksandr-pavlyk : Warning and error @PokhodenkoSA (#184 (comment) ) did not find after making changes. Commands for the conda virtual environment: |
Please, format code with black formatter. |
return self | ||
|
||
def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): | ||
if method == "__call__": |
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.
Need to also handle method="accumulate"
, "reduce"
, "reduceat"
, "outer"
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.
Can we add a TODO and open a ticket to track this future work.
… MemInfo. We'll have to add __sycl_usm_array_interface__ property to Numba objects to get this equivalent behavior without this dependency in the wrong direction.
one general comment; I want to add the new |
dpctl/tests/test_dparray.py
Outdated
def test_dparray_through_python_func(self): | ||
def func_operation_with_const(dpctl_array): | ||
return dpctl_array * 2.0 + 13 | ||
|
||
C = self.X * 5 | ||
dp_func = func_operation_with_const(C) | ||
self.assertIsInstance(dp_func, dparray.ndarray) | ||
|
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.
Why this test is deleted?
@vlad-perevezentsev
@vlad-perevezentsev Please, make it in separate PR. |
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.
LGTM.
|
return self | ||
|
||
def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): | ||
if method == "__call__": |
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.
Can we add a TODO and open a ticket to track this future work.
|
I would like a name that reflects that it can be imported as a full numpy replacement. "dparray" doesn't quite capture that but "_ndarray_subclass" I think could even more so give the wrong impression. At some point we want to call dpnp from there so you're going to get much more than just an ndarray replacement. |
|
||
# Tell Numba to not treat this type just like a NumPy ndarray but to propagate its type. | ||
# This way it will use the custom dparray allocator. | ||
__numba_no_subtype_ndarray__ = True |
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.
@DrTodd13 Do we really need this extra attribute? Can we not use the facts that the array is a subclass of NumPy.ndarray and it defines the __sycl_usm_array_interface__
to recognize this class inside Numba?
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.
Numba is currently made to treat Numpy.ndarray subclasses as if they were Numpy.ndarrays. Therefore, we can't just check for whether it is a ndarray subclass to keep those types separate without breaking backwards compatibility.
Also, you might want to keep types separate even if you don't need a special allocator. So, for generality, we shouldn't specialize on something allocator or USM-specific inside Numba.
|
@diptorupd Why did you close this PR? What is the plan for it now? |
@PokhodenkoSA not sure when/what I did. Must have accidentally clicked wrong button. |
Remove `include dparray.py`
Not necessary. #200 could be merged later. #200 depends on #192. #200 is independent. |
This PR contains all the changes in #192, #200. I will close those two PRs after merging this one. Pending issues to improve the dparray implementation are to be addressed as follow up PRs. Thanks @DrTodd13 @oleksandr-pavlyk @vlad-perevezentsev for working on this PR.
This code is from #184 placed in common branch.
From #192 (comment):