dpnp.ogrid
- dpnp.ogrid = <dpnp.dpnp_iface_arraycreation.OGridClass object>
Construct an open multi-dimensional "meshgrid".
For full documentation refer to
numpy.ogrid
.- Parameters:
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 -- Returns a tuple of arrays, with grid[i].shape = (1, ..., 1, dimensions[i], 1, ..., 1) with dimensions[i] in the i-th place.
- Return type:
one dpnp.ndarray or tuple of dpnp.ndarray
Examples
>>> import dpnp as np >>> np.ogrid[0:5, 0:5] [array([[0], [1], [2], [3], [4]]), array([[0, 1, 2, 3, 4]])]
Creating an array on a different device or with a specified usm_type
>>> x = np.ogrid[-1:1:5j] # default case >>> x, x.device, x.usm_type (array([-1. , -0.5, 0. , 0.5, 1. ]), Device(level_zero:gpu:0), 'device')
>>> y = np.ogrid(device="cpu")[-1:1:5j] >>> y, y.device, y.usm_type (array([-1. , -0.5, 0. , 0.5, 1. ]), Device(opencl:cpu:0), 'device')
>>> z = np.ogrid(usm_type="host")[-1:1:5j] >>> z, z.device, z.usm_type (array([-1. , -0.5, 0. , 0.5, 1. ]), Device(level_zero:gpu:0), 'host')