dpnp.asfarray

dpnp.asfarray(a, dtype=None, *, device=None, usm_type=None, sycl_queue=None)[source]

Return an array converted to a float type.

For full documentation refer to numpy.asfarray.

Parameters:
  • a (array_like) -- Input data, in any form that can be converted to an array. This includes an instance of dpnp.ndarray or dpctl.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 (str or dtype object, optional) -- Float type code to coerce input array a. If dtype is None, dpnp.bool or one of the int dtypes, it is replaced with the default floating type (dpnp.float64 if a device supports it, or dpnp.float32 type otherwise).

  • device ({None, string, SyclDevice, SyclQueue}, optional) -- An array API concept of device where the output array is created. The device can be None (the default), an OneAPI filter selector string, an instance of dpctl.SyclDevice corresponding to a non-partitioned SYCL device, an instance of dpctl.SyclQueue, or a Device object returned by dpnp.ndarray.device property.

  • usm_type ({None, "device", "shared", "host"}, optional) -- The type of SYCL USM allocation for the output array.

  • sycl_queue ({None, SyclQueue}, optional) -- A SYCL queue to use for output array allocation and copying.

Returns:

out -- The input a as a float ndarray.

Return type:

dpnp.ndarray

Examples

>>> import dpnp as np
>>> np.asfarray([2, 3])
array([2.,  3.])
>>> np.asfarray([2, 3], dtype=dpnp.float32)
array([2., 3.], dtype=float32)
>>> np.asfarray([2, 3], dtype=dpnp.int32)
array([2.,  3.])