fn

repeat

Tensor
repeat(x: Tensor, repeats: _int, dim: _int | None = None)
source

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

xTensor
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])