-
Notifications
You must be signed in to change notification settings - Fork 31
Feature/asarray #646
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
Feature/asarray #646
Conversation
|
@oleksandr-pavlyk Do we have a test where we are testing the equality of shape of new array created using |
|
Is this good enough? |
|
The description of this PR has more documentation than functions docstrings you created in code. |
| """Represents object `obj` as usm_ndarray""" | ||
| # 1. Check that copy is a valid keyword | ||
| if copy not in [None, True, False]: | ||
| raise TypeError( |
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.
Seems ValueError is more suitable here.
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.
I disagree, in my mind the check is asking if copy is of bool type, or of None type.
|
View rendered docs @ https://intelpython.github.io/dpctl/pulls/646/index.html |
1008e30 to
c43c2b6
Compare
9f0c8c2 to
7a580f6
Compare
930d8a7 to
2429d99
Compare
|
@diptorupd @densmirn @reazulhoque @Alexander-Makaryev @PokhodenkoSA This PR is now feature complete and changed from draft to "ready for review". I cleaned up commit history to reduce it from 32 commits to 10 commit, |
```
dpctl.tensor.asarray(
obj, dtype=None, copy=None, order="C",
device=None, usm_type=None, sycl_queue=None
)
```
```
dpctl.tensor.empty(
shape,
dtype="f8", order="C", device=None,
usm_type=None, sycl_queue=None
)
```
1. Check validation of arguments is `asarray` 2. Check that `asarray` works with objects exposing `__sycl_usm_array_interface__`. Adding a test with scalar arguments, tests to cover input validation, tests for copy=False
Change default of asarray's order keyword from "K" to "C" Fixed issue pointed out by Denis (processing of order in empty) Added support for objects with buffer protocol in asarray.
…m queue to sycl_queue
2429d99 to
12d6693
Compare
I added docstrings. |
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.
Tested manually with DuckUSMArray to make sure integration with Numba-dppy is working correctly.
|
Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞 |
Closes #640 . Adds
dpctl.tensor.asarrayanddpctl.tensor.empty.Create an empty
dpctl.tensor.usm_ndarrayobject of requesteddtypeand based on request USM allocation type on specified array-APIdevice, and of requested layout specified byorderkeyword.Instead of specifying array-API device keyword,
sycl_queuecan be used to specify the target of allocation instead.Converts Python object
objtousm_ndarrayobject. Support objects are:usm_ndarrayinstancesnumpy.ndarrayinstances__sycl_usm_array_interface__.