dpctl.tensor.asarray¶
- dpctl.tensor.asarray(obj, /, *, dtype=None, device=None, copy=None, usm_type=None, sycl_queue=None, order='K')[source]¶
Converts input object to
dpctl.tensor.usm_ndarray
.- Parameters:
obj – Python object to convert. Can be an instance of
dpctl.tensor.usm_ndarray
, an object representing SYCL USM allocation and implementing__sycl_usm_array_interface__
protocol, an instance ofnumpy.ndarray
, an object supporting Python buffer protocol, a Python scalar, or a (possibly nested) sequence of Python scalars.dtype (data type, optional) – output array data type. If
dtype
isNone
, the output array data type is inferred from data types inobj
. Default:None
copy (bool, optional) – boolean indicating whether or not to copy the input. If
True
, always creates a copy. IfFalse
, the need to copy raisesValueError
. IfNone
, tries to reuse existing memory allocations if possible, but allows to perform a copy otherwise. Default:None
order (
"C"
,"F"
,"A"
,"K"
, optional) – memory layout of the output array. Default:"K"
device (optional) – array API concept of device where the output array is created.
device
can beNone
, a oneAPI filter selector string, an instance ofdpctl.SyclDevice
corresponding to a non-partitioned SYCL device, an instance ofdpctl.SyclQueue
, or adpctl.tensor.Device
object returned bydpctl.tensor.usm_ndarray.device
. Default:None
usm_type (
"device"
,"shared"
,"host"
, optional) – The type of SYCL USM allocation for the output array. Default:"device"
sycl_queue (
dpctl.SyclQueue
, optional) – The SYCL queue to use for output array allocation and copying.sycl_queue
anddevice
are complementary arguments, i.e. use one or another. If both are specified, aTypeError
is raised unless both imply the same underlying SYCL queue to be used. If both areNone
, a cached queue targeting default-selected device is used for allocation and population. Default:None
- Returns:
Array created from input object.
- Return type: