dpnp.mgrid¶
- dpnp.mgrid = <dpnp.dpnp_iface_arraycreation.MGridClass object>¶
Construct a dense multi-dimensional "meshgrid".
For full documentation refer to
numpy.mgrid.- Parameters:
- device{None, string, SyclDevice, SyclQueue, Device}, optional
An array API concept of device where the output array is created. device can be
None, a oneAPI filter selector string, an instance ofdpctl.SyclDevicecorresponding to a non-partitioned SYCL device, an instance ofdpctl.SyclQueue, or adpnp.tensor.Deviceobject returned bydpnp.ndarray.device.Default:
None.- 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:
- outdpnp.ndarray
A single array, containing a set of arrays all of the same dimensions, stacked along the first axis.
See also
dpnp.ogridWork like
dpnp.mgridbut returns open (not fleshed out) mesh grids.dpnp.meshgridReturn coordinate matrices from coordinate vectors.
dpnp.r_Array concatenator.
Examples
>>> import dpnp as np >>> np.mgrid[0:5, 0:5] array([[[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [4, 4, 4, 4, 4]], [[0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4]]])
>>> np.mgrid[0:4].shape (4,) >>> np.mgrid[0:4, 0:5].shape (2, 4, 5) >>> np.mgrid[0:4, 0:5, 0:6].shape (3, 4, 5, 6)
Creating an array on a different device or with a specified usm_type
>>> x = np.mgrid[-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.mgrid(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.mgrid(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')