---
title: "ClikaRT::ops::roll"
sidebar_label: "roll"
description: "Circularly shift elements: shifts[i] positions along dims[i]; elements that fall off one end re-enter at the other."
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--function">function</span>

## roll() {#roll}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`roll`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const std::int64_t>` `shifts`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const std::int64_t>` `dims` `=` `{}`<br />
)

</div>

Circularly shift elements: `shifts[i]` positions along `dims[i]`; elements that fall off one end re-enter at the other.

With `dims` empty (the default) the tensor is treated as flattened row-major and shifted by `shifts[0]`. Copies.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when `shifts` and `dims` lengths disagree (`code_name()` carries the reason).

**Returns:** a new tensor, `input`'s shape and dtype.

<div class="api-declared">

Declared in `ClikaRT/compute/ops.h`, line 3427

</div>
