dpnp.full_like

dpnp.full_like(a, /, fill_value, *, dtype=None, order='C', subok=False, shape=None, device=None, usm_type=None, sycl_queue=None)[source]

Return a full array with the same shape and type as a given array.

For full documentation refer to numpy.full_like.

Parameters:
  • a ({dpnp_array, usm_ndarray}) -- The shape and dtype of a define these same attributes of the returned array.

  • fill_value ({scalar, array_like}) -- Fill value, 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 ({None, dtype}, optional) -- The desired dtype for the array, e.g., dpnp.int32. Default is the default floating point data type for the device where input array is allocated.

  • order ({"C", "F", None}, optional) -- Memory layout of the newly output array. Default: "C".

  • shape ({int, sequence of ints}) -- Overrides the shape of the result.

  • 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.dpnp_array.dpnp_array.device property.

  • 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 of fill_value with the same shape and type as a.

Return type:

dpnp.ndarray

Limitations

Parameter order is supported only with values "C", "F" and None. Parameter subok is supported only with default value False. Otherwise, the function raises NotImplementedError exception.

See also

dpnp.empty_like

Return an empty array with shape and type of input.

dpnp.ones_like

Return an array of ones with shape and type of input.

dpnp.zeros_like

Return an array of zeros with shape and type of input.

dpnp.full

Return a new array of given shape filled with value.

Examples

>>> import dpnp as np
>>> a = np.arange(6)
>>> np.full_like(a, 1)
array([1, 1, 1, 1, 1, 1])

Creating an array on a different device or with a specified usm_type

>>> x = np.full_like(a, 1) # default case
>>> x, x.device, x.usm_type
(array([1, 1, 1, 1, 1, 1]), Device(level_zero:gpu:0), 'device')
>>> y = np.full_like(a, 1, device="cpu")
>>> y, y.device, y.usm_type
(array([1, 1, 1, 1, 1, 1]), Device(opencl:cpu:0), 'device')
>>> z = np.full_like(a, 1, usm_type="host")
>>> z, z.device, z.usm_type
(array([1, 1, 1, 1, 1, 1]), Device(level_zero:gpu:0), 'host')