Skip to content
fn

repeat

→Tensor
repeat(input: Tensor, repeats: _int, dim: _int | None = None)

Implementing kernel

C++ engine symbols that back this Python API.

Tile a tensor along an existing dimension.

Replicates input as a whole block repeats times along dim. Contrast with repeat_interleave, which replicates each element individually ([1, 1, 2, 2] vs. [1, 2, 1, 2]).

Parameters

inputTensor
Source tensor.
repeatsint
Number of block repetitions.
dimint= None
Dimension along which to repeat. None flattens first.

Returns

Tensor

Newly-allocated tensor — repeating always copies.

Notes

For multi-dim tiling patterns use tile, which accepts a per-axis repetition vector.

Examples

>>> import lucid
>>> x = lucid.tensor([1, 2, 3])
>>> lucid.repeat(x, 2, dim=0)
Tensor([1, 2, 3, 1, 2, 3])