dpnp.tensor.asarray

dpnp.tensor.asarray(obj, /, *, dtype=None, device=None, copy=None, usm_type=None, sycl_queue=None, order='K')[source]

Converts input object to dpnp.tensor.usm_ndarray.

Parameters:
  • obj (array_like) -- Python object to convert. Can be an instance of dpnp.tensor.usm_ndarray, an object representing SYCL USM allocation and implementing __sycl_usm_array_interface__ protocol, an instance of numpy.ndarray, an object supporting Python buffer protocol, a Python scalar, or a (possibly nested) sequence of Python scalars.

  • dtype ({None, dtype}, optional) --

    output array data type. If dtype is None, the output array data type is inferred from data types in obj.

    Default: None.

  • copy ({None, bool}, optional) --

    boolean indicating whether or not to copy the input. If True, always creates a copy. If False, the need to copy raises ValueError. If None, 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 ({None, object}, optional) --

    array API concept of device where the output array is created. device can be None, a oneAPI filter selector string, an instance of dpctl.SyclDevice corresponding to a non-partitioned SYCL device, an instance of dpctl.SyclQueue, or a dpnp.tensor.Device object returned by dpnp.tensor.usm_ndarray.device.

    Default: None.

  • usm_type ({None, "device", "shared", "host"}, optional) --

    The type of SYCL USM allocation for the output array.

    Default: "device".

  • sycl_queue ({None, dpctl.SyclQueue}, optional) --

    The SYCL queue to use for output array allocation and copying. sycl_queue and device are complementary arguments, i.e. use one or another. If both are specified, a TypeError is raised unless both imply the same underlying SYCL queue to be used. If both are None, a cached queue targeting default-selected device is used for allocation and population.

    Default: None.

Returns:

out -- Array created from input object.

Return type:

usm_ndarray