Skip to main content

ClikaRT::ops::repeat_interleave

function

repeat_interleave()

Tensor repeat_interleave(
    Tensor x,
    ScalarOrTensor repeats,
    std::optional<int64_t> dim = std::nullopt,
    std::optional<int64_t> output_size = std::nullopt
)

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.

Declared in ClikaRT/compute/ops.h, line 3322