-
Notifications
You must be signed in to change notification settings - Fork 30
asarray supports sequence of arrays from multiple devices #1151
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
asarray supports sequence of arrays from multiple devices #1151
Conversation
``` In [1]: import dpctl, dpctl.tensor as dpt In [2]: m = dpt.zeros((2, 4), dtype="i2", device="cpu") In [3]: w = dpt.full(4, -1, device="opencl:gpu") In [4]: res = dpt.asarray([m, [w, [0,] * 4 ]], dtype="f4", device="cpu") In [5]: res Out[5]: usm_ndarray([[[ 0., 0., 0., 0.], [ 0., 0., 0., 0.]], [[-1., -1., -1., -1.], [ 0., 0., 0., 0.]]], dtype=float32) In [6]: res.device Out[6]: Device(opencl:cpu:0) ``` This usage requires user to specify sycl_queue or device keyword to indicate where the result is created, or ExecitionPlacementError is raised.
Array API standard conformance tests for dpctl=0.14.3dev0=py310h76be34b_65 ran successfully. |
Array API standard conformance tests for dpctl=0.14.3dev0=py310h76be34b_66 ran successfully. |
View rendered docs @ https://intelpython.github.io/dpctl/pulls/1151/index.html |
``` import dpnp, numpy, dpctl, dpctl.tensor as dpt w = dpt.full(4, -1, device="opencl:gpu") res = dpt.asarray([w, range(4)], dtype="f4") # now correctly infers where to allocate output array ``` ``` import dpctl, dpctl.tensor as dpt m = dpt.zeros((2, 4), dtype="i2", device="cpu") w = dpt.full(4, -1, device="opencl:gpu") res = dpt.asarray([m, [w, range(4)], dtype="f4", device="cpu") ```
Array API standard conformance tests for dpctl=0.14.3dev0=py310h76be34b_72 ran successfully. |
Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞 |
Array API standard conformance tests for dpctl=0.14.3dev0=py310h76be34b_74 ran successfully. |
Added support for
asarray
to create arrays from sequences of usm_ndarray objects allocated on different devices, and other Python sequences or numpy arrays.