dpnp.from_dlpack
- dpnp.from_dlpack(obj, /, *, device=None, copy=None)[source]
Create a dpnp array from a Python object implementing the
__dlpack__protocol.See https://dmlc.github.io/dlpack/latest/ for more details.
- Parameters:
obj (object) -- A Python object representing an array that implements the
__dlpack__and__dlpack_device__methods.device ({
dpctl.SyclDevice,dpctl.SyclQueue,) --dpctl.tensor.Device, tuple, None}, optional Array API concept of a device where the output array is to be placed.devicecan beNone, an oneAPI filter selector string, an instance ofdpctl.SyclDevicecorresponding to a non-partitioned SYCL device, an instance ofdpctl.SyclQueue, adpctl.tensor.Deviceobject returned bydpctl.tensor.usm_ndarray.device, or a 2-tuple matching the format of the output of the__dlpack_device__method, an integer enumerator representing the device type followed by an integer representing the index of the device. Default:None.{bool (copy) --
Boolean indicating whether or not to copy the input.
If copy``is ``True`, the input will always be copied.
If
False, aBufferErrorwill be raised if a copy is deemed necessary.If
None, a copy will be made only if deemed necessary, otherwise, the existing memory buffer will be reused.
Default:
None.None} --
Boolean indicating whether or not to copy the input.
If copy``is ``True`, the input will always be copied.
If
False, aBufferErrorwill be raised if a copy is deemed necessary.If
None, a copy will be made only if deemed necessary, otherwise, the existing memory buffer will be reused.
Default:
None.optional --
Boolean indicating whether or not to copy the input.
If copy``is ``True`, the input will always be copied.
If
False, aBufferErrorwill be raised if a copy is deemed necessary.If
None, a copy will be made only if deemed necessary, otherwise, the existing memory buffer will be reused.
Default:
None.
- Returns:
out -- Returns a new dpnp array containing the data from another array (obj) with the
__dlpack__method on the same device as object.- Return type:
- Raises:
TypeError: -- if obj does not implement
__dlpack__methodValueError: -- if the input array resides on an unsupported device