-
Notifications
You must be signed in to change notification settings - Fork 30
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
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.asarray
anddpctl.tensor.empty
.Create an empty
dpctl.tensor.usm_ndarray
object of requesteddtype
and based on request USM allocation type on specified array-APIdevice
, and of requested layout specified byorder
keyword.Instead of specifying array-API device keyword,
sycl_queue
can be used to specify the target of allocation instead.Converts Python object
obj
tousm_ndarray
object. Support objects are:usm_ndarray
instancesnumpy.ndarray
instances__sycl_usm_array_interface__
.