You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tensor.asarray support for objects with __usm_ndarray__ attribute added
`asarray` supports objects that implement `__sycl_usm_array_interface__`.
It can create a view into USM allocation owned by input object, hence maintains
a reference to it.
Asynchronous deallocation of such objects in dpctl.tensor functions require
manipulating Python object reference counters, and hold GIL. This is a source
of dead-locks, and affects performance.
This PR adds support for ingesting Python objects that implement __usm_ndarray__
attribute (property) that returns dpt.usm_ndarray object with such a view directly.
It is trivial for `dpnp.ndarray` to implement such a property, e.g,.
```
@Property
def __usm_ndarray__(self):
return self._array_obj
```
With this definition, `dpt.asarray(dpnp_array)` will recognize that the underlying
USM allocation is managed by the smart pointer, and asynchronous deallocation will
not involve Python objects, avoiding dead-locks and improving performance.
0 commit comments