dpnp.tensor.roll

dpnp.tensor.roll(x, /, shift, *, axis=None)[source]

Rolls array elements along a specified axis. Array elements that roll beyond the last position are re-introduced at the first position. Array elements that roll beyond the first position are re-introduced at the last position.

Parameters:
  • x (usm_ndarray) -- Input array.

  • shift ({int, tuple of ints}) -- Number of places by which the elements are shifted. If shift is a tuple, then axis must be a tuple of the same size, and each of the given axes must be shifted by the corresponding element in shift. If shift is an int and axis a tuple, then the same shift must be used for all specified axes. If a shift is positive, then array elements is shifted positively (toward larger indices) along the dimension of axis. If a shift is negative, then array elements must be shifted negatively (toward smaller indices) along the dimension of axis.

  • axis ({None, int, tuple of ints}, optional) --

    Axis (or axes) along which elements to shift. If axis is None, the array is flattened, shifted, and then restored to its original shape.

    Default: None.

Returns:

out -- An array having the same dtype, usm_type and device attributes as x and whose elements are shifted relative to x.

Return type:

usm_ndarray