dpnp.empty
- dpnp.empty(shape, *, dtype=None, order='C', like=None, device=None, usm_type='device', sycl_queue=None)[source]
Return a new array of given shape and type, without initializing entries.
For full documentation refer to
numpy.empty
.- Parameters:
shape ({int, sequence of ints}) -- Shape of the new array, e.g., (2, 3) or 2.
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 ({None, "C", "F"}, 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 ofdpctl.SyclDevice
corresponding to a non-partitioned SYCL device, an instance ofdpctl.SyclQueue
, or a Device object returned bydpnp.dpnp_array.dpnp_array.device
property.usm_type ({None, "device", "shared", "host"}, optional) -- The type of SYCL USM allocation for the output array. Default:
"device"
.sycl_queue ({None, SyclQueue}, optional) -- A SYCL queue to use for output array allocation and copying. The sycl_queue can be passed as
None
(the default), which means to get the SYCL queue from device keyword if present or to use a default queue. Default:None
.
- Returns:
out -- Array of uninitialized data of the given shape, dtype, and order.
- Return type:
dpnp.ndarray
Limitations
Parameter like is supported only with default value
None
. Otherwise, the function raisesNotImplementedError
exception.See also
dpnp.empty_like
Return an empty array with shape and type of input.
dpnp.ones
Return a new array setting values to one.
dpnp.zeros
Return a new array setting values to zero.
dpnp.full
Return a new array of given shape filled with value.
Examples
>>> import dpnp as np >>> np.empty(4) array([9.03088525e-312, 9.03088525e-312, 9.03088525e-312, 9.03088525e-312])
Creating an array on a different device or with a specified usm_type
>>> x = np.empty((3, 3)) # default case >>> x.shape, x.device, x.usm_type ((3, 3), Device(level_zero:gpu:0), 'device')
>>> y = np.empty((3, 3), device="cpu") >>> y.shape, y.device, y.usm_type ((3, 3), Device(opencl:cpu:0), 'device')
>>> z = np.empty((3, 3), usm_type="host") >>> z.shape, z.device, z.usm_type ((3, 3), Device(level_zero:gpu:0), 'host')