---
title: "ClikaRT::ops::repeat_interleave"
sidebar_label: "repeat_interleave"
description: "Repeat ELEMENTS, not blocks: each element along dim appears repeats times consecutively ([a, b] with repeats 2 -> [a, a, b, b])."
---

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

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

## repeat\_interleave() {#repeat_interleave}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`repeat_interleave`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ScalarOrTensor`](../ScalarOrTensor.md) `repeats`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::optional<int64_t>` `dim` `=` `std::nullopt`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::optional<int64_t>` `output_size` `=` `std::nullopt`<br />
)

</div>

Repeat ELEMENTS, not blocks: each element along `dim` appears `repeats` times consecutively (`[a, b]` with repeats 2 -\> `[a, a, b, b]`).

`repeats` is a scalar (uniform count) or a 1-D tensor matching the dim's length (per-element counts, output length = their sum). With `dim` absent the input is flattened first. `output_size` is the known result length along the dim; pass it when the caller already has it, so a tensor-valued `repeats` skips the blocking host-side count. Copies.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when `repeats` is negative or its length mismatches the dim (`code_name()` carries the reason).

**Returns:** a new tensor with the chosen dim scaled by the repeat counts.

<div class="api-declared">

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

</div>
