IntelPython / dpnp

Data Parallel Extension for NumPy
BSD 2-Clause "Simplified" License
98 stars 22 forks source link

`dpnp.array` doesn't return `dpnp.ndarray` #1570

Closed samir-nasibli closed 1 year ago

samir-nasibli commented 1 year ago

Description

dpnp.array returns the same object, it is expected that it will return wrapped dpnp.ndarray with the same __sycl_usm_arrray_interface__.

>>> import dpctl
>>> import dpctl.tensor as dpt
>>> import dpnp
>>> dpctl_arr = dpctl.tensor.zeros(12, usm_type="device", sycl_queue=dpctl.SyclQueue("gpu"))
>>> dpctl_arr
usm_ndarray([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
>>> result = dpnp.array(dpctl_arr, copy=False)
>>> result
usm_ndarray([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
>>> type(result)
<class 'dpctl.tensor._usmarray.usm_ndarray'>

Env

Python 3.10.13

conda list | grep dp
dpctl                     0.15.0rc2
dpnp                      0.13.0rc2
mkl-dpcpp                 2024.0.0
vlad-perevezentsev commented 1 year ago

This issue was solved by #1571 It was due to #1526 which added a new condition in def asarray to return the input argument if dpctl returns zero copying but did not check the case when the input array is usm_ndarray. Thanks for creating the issue .