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.device
can beNone
, an oneAPI filter selector string, an instance ofdpctl.SyclDevice
corresponding to a non-partitioned SYCL device, an instance ofdpctl.SyclQueue
, adpctl.tensor.Device
object 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
, aBufferError
will 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
, aBufferError
will 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
, aBufferError
will 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