# tensorplay.functional.roll Source: https://www.tensorplay.cn/docs/generated/tensorplay.functional.roll.html ```python tensorplay.functional.roll(input, shifts, dims=None) → Tensor ``` Roll the tensor input along the given dimension(s). Elements that are shifted beyond the last position are re-introduced at the first position. If dims is None, the tensor will be flattened before rolling and then restored to the original shape. Parameters: - input ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – the input tensor. - shifts ([int](https://docs.python.org/3/builtins/functions.html#int) or [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple) of ints) – The number of places by which the elements of the tensor are shifted. If shifts is a tuple, dims must be a tuple of the same size, and each dimension will be rolled by the corresponding value - dims ([int](https://docs.python.org/3/builtins/functions.html#int) or [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple) of ints) – Axis along which to roll Example: ``` >>> x = tensorplay.tensor([1, 2, 3, 4, 5, 6, 7, 8]).view(4, 2) >>> x tensor([[1, 2], [3, 4], [5, 6], [7, 8]]) >>> tensorplay.roll(x, 1) tensor([[8, 1], [2, 3], [4, 5], [6, 7]]) >>> tensorplay.roll(x, 1, 0) tensor([[7, 8], [1, 2], [3, 4], [5, 6]]) >>> tensorplay.roll(x, -1, 0) tensor([[3, 4], [5, 6], [7, 8], [1, 2]]) >>> tensorplay.roll(x, shifts=(2, 1), dims=(0, 1)) tensor([[6, 5], [8, 7], [2, 1], [4, 3]]) ```