dpnp.asanyarray
- dpnp.asanyarray(a, dtype=None, order=None, *, like=None, device=None, usm_type=None, sycl_queue=None)[source]
Convert the input to an
dpnp.ndarray.For full documentation refer to
numpy.asanyarray.- Parameters:
a (array_like) – Input data, in any form that can be converted to an array. This includes scalars, lists, lists of tuples, tuples, tuples of tuples, tuples of lists, and ndarrays.
dtype (dtype, optional) – The desired dtype for the array. If not given, a default dtype will be used that can represent the values (by considering Promotion Type Rule and device capabilities when necessary).
order ({"C", "F", "A", "K"}, optional) – Memory layout of the newly output array. Default: “K”.
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 ofdpctl.SyclDevicecorresponding to a non-partitioned SYCL device, an instance ofdpctl.SyclQueue, or a Device object returned bydpnp.dpnp_array.dpnp_array.deviceproperty.usm_type ({None, "device", "shared", "host"}, optional) – The type of SYCL USM allocation for the output array. Default is
None.sycl_queue ({None, SyclQueue}, optional) – A SYCL queue to use for output array allocation and copying.
- Returns:
out – Array interpretation of a.
- Return type:
dpnp.ndarray
Limitations
Parameter like is supported only with default value
None. Otherwise, the function raises NotImplementedError exception.See also
dpnp.asarraySimilar function which always returns ndarrays.
dpnp.ascontiguousarrayConvert input to a contiguous array.
dpnp.asfarrayConvert input to a floating point ndarray.
dpnp.asfortranarrayConvert input to an ndarray with column-major memory order.
dpnp.asarray_chkfiniteSimilar function which checks input for NaNs and Infs.
dpnp.fromiterCreate an array from an iterator.
dpnp.fromfunctionConstruct an array by executing a function on grid positions.
Examples
>>> import dpnp as np >>> np.asanyarray([1, 2, 3]) array([1, 2, 3])
Creating an array on a different device or with a specified usm_type
>>> x = np.asanyarray([1, 2, 3]) # default case >>> x, x.device, x.usm_type (array([1, 2, 3]), Device(level_zero:gpu:0), 'device')
>>> y = np.asanyarray([1, 2, 3], device="cpu") >>> y, y.device, y.usm_type (array([1, 2, 3]), Device(opencl:cpu:0), 'device')
>>> z = np.asanyarray([1, 2, 3], usm_type="host") >>> z, z.device, z.usm_type (array([1, 2, 3]), Device(level_zero:gpu:0), 'host')