dpnp.arange
- dpnp.arange(start, /, stop=None, step=1, *, dtype=None, like=None, device=None, usm_type='device', sycl_queue=None)[source]
Returns an array with evenly spaced values within a given interval.
For full documentation refer to
numpy.arange
.- Parameters:
start ({int, real}, optional) -- Start of interval. The interval includes this value. The default start value is 0.
stop ({int, real}) -- End of interval. The interval does not include this value, except in some cases where step is not an integer and floating point round-off affects the length of out.
step ({int, real}, optional) -- Spacing between values. The default step size is 1. If step is specified as a position argument, start must also be given.
dtype ({None, 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).
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 -- The 1-D array containing evenly spaced values.
- Return type:
dpnp.ndarray
Limitations
Parameter like is supported only with default value
None
. Otherwise, the function raisesNotImplementedError
exception.See also
dpnp.linspace
Evenly spaced numbers with careful handling of endpoints.
Examples
>>> import dpnp as np >>> np.arange(3) array([0, 1, 2]) >>> np.arange(3, 7) array([3, 4, 5, 6]) >>> np.arange(3, 7, 2) array([3, 5])
Creating an array on a different device or with a specified usm_type
>>> x = np.arange(3) # default case >>> x, x.device, x.usm_type (array([0, 1, 2]), Device(level_zero:gpu:0), 'device')
>>> y = np.arange(3, device="cpu") >>> y, y.device, y.usm_type (array([0, 1, 2]), Device(opencl:cpu:0), 'device')
>>> z = np.arange(3, usm_type="host") >>> z, z.device, z.usm_type (array([0, 1, 2]), Device(level_zero:gpu:0), 'host')