dpnp.ndarray.strides
property
- property ndarray.strides
Tuple of bytes to step in each dimension when traversing an array.
The byte offset of element
(i[0], i[1], ..., i[n])in an array a is:offset = sum(dpnp.array(i) * a.strides)
For full documentation refer to
numpy.ndarray.strides.See also
dpnp.lib.stride_tricks.as_stridedReturn a view into the array with given shape and strides.
Examples
>>> import dpnp as np >>> y = np.reshape(np.arange(2 * 3 * 4, dtype=np.int32), (2, 3, 4)) >>> y array([[[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]], [[12, 13, 14, 15], [16, 17, 18, 19], [20, 21, 22, 23]]], dtype=np.int32) >>> y.strides (48, 16, 4) >>> y[1, 1, 1] array(17, dtype=int32) >>> offset = sum(i * s for i, s in zip((1, 1, 1), y.strides)) >>> offset // y.itemsize 17
>>> x = np.reshape(np.arange(5*6*7*8, dtype=np.int32), (5, 6, 7, 8)) >>> x = x.transpose(2, 3, 1, 0) >>> x.strides (32, 4, 224, 1344) >>> offset = sum(i * s for i, s in zip((3, 5, 2, 2), x.strides)) >>> x[3, 5, 2, 2] array(813, dtype=int32) >>> offset // x.itemsize 813