dpnp.full

dpnp.full(shape, fill_value, *, dtype=None, order='C', like=None, device=None, usm_type=None, sycl_queue=None)[source]

Return a new array of given shape and type, filled with fill_value.

For full documentation refer to numpy.full.

Parameters:
  • shape ({int, sequence of ints}) -- Shape of the new array, e.g., (2, 3) or 2.

  • 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".

  • 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 given shape, dtype, and order.

Return type:

dpnp.ndarray

Limitations

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

See also

dpnp.full_like

Return a new array with shape of input filled with value.

dpnp.empty

Return a new uninitialized array.

dpnp.ones

Return a new array setting values to one.

dpnp.zeros

Return a new array setting values to zero.

Examples

>>> import dpnp as np
>>> np.full(4, 10)
array([10, 10, 10, 10])

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

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