Skip to content
fn

repeat_op

→TensorImplPtr
int repeat_op(const int & a, int repeats, int axis)

Python wrappers

Public Python APIs implemented by this engine symbols.

Repeat the contents of a tensor along a single axis.

Produces an output whose axis dimension is repeats times larger than the input's; every other dimension is unchanged. Each element along axis is replicated as a contiguous block of repeats copies in the output (this is interleaved repetition, distinct from tile_op).

Math

y[…,ia,…]=x[…,⌊ia/r⌋,…]y_{[\ldots, i_a, \ldots]} = x_{[\ldots, \lfloor i_a / r \rfloor, \ldots]} where r=r = repeats and iai_a is the index along axis.

Shape

out.shape[axis] = a.shape[axis] * repeats; all other dims unchanged.

See Also

tile_op — multi-axis tiling; different element ordering.

Parameters

aTensorImplPtr
Input tensor.
repeatsint64_t
Number of times to repeat along axis. Must be > 0.
axisint
Axis along which to repeat. Supports negative indexing.

Returns

TensorImplPtr

Tensor of shape a.shape with the axis dimension scaled by repeats.

Notes

Backward sums the repeated gradient blocks back into the original shape via Dispatcher::repeat_backward. Schema name "repeat", AmpPolicy::KeepInput.