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
The function takes an object with `__sycl_usm_array_interface__`
and creates approproate MemoryUSM* object depending the the type of
USM alocation the argument represents.
Example:
```
In [1]: import dpctl, dpctl.memory as dpm, dpctl.memory._memory as dpm_m
In [2]: import dpctl.tensor as dpt
In [3]: X = dpt.usm_ndarray((4, 5))
In [4]: dpm_m.create_MemoryUSM(X)
Out[4]: <SYCL(TM) USM-device allocated memory block of 160 bytes at 0xffffd556aa5f0000>
In [5]: X.usm_data
Out[5]: <SYCL(TM) USM-device allocated memory block of 160 bytes at 0xffffd556aa5f0000>
In [6]: class Duck_USMAllocation:
...: def __init__(self, buf, syclobj):
...: self.buf_ = buf
...: self.syclobj_ = syclobj
...:
In [7]: class Duck_USMAllocation:
...: def __init__(self, buf, syclobj):
...: self.buf_ = buf
...: self.syclobj_ = syclobj
...: @Property
...: def __sycl_usm_array_interface__(self):
...: iface = self.buf_.__sycl_usm_array_interface__
...: iface['syclobj'] = self.syclobj_
...: return iface
...:
In [8]: d = Duck_USMAllocation(X, X.sycl_device.filter_string)
In [9]: dpm_m.create_MemoryUSM(d)
Out[9]: <SYCL(TM) USM-device allocated memory block of 160 bytes at 0xffffd556aa5f0000>
```
0 commit comments