Skip to content
fn

tile_op

→TensorImplPtr
int tile_op(const int & a, int reps)

Python wrappers

Public Python APIs implemented by this engine symbol.

Tile a tensor by repeating it along multiple axes.

reps[d] specifies how many times to repeat along dimension d. If reps is longer than a.rank(), the input is conceptually left-padded with size-1 dimensions before tiling, so the output rank equals reps.size().

Math

y[i0,…,ir−1]=x[i0 mod D0,…,ir−1 mod Dr−1]y_{[i_0, \ldots, i_{r-1}]} = x_{[i_0 \bmod D_0, \ldots, i_{r-1} \bmod D_{r-1}]} where DdD_d is the input's effective size along dimension dd.

Shape

Let r = reps.size() and n = a.rank(). After left-padding a with max(r - n, 0) size-1 dims: out.shape[d] = a_padded.shape[d] * reps[d] for d in [0, max(r, n)).

See Also

repeat_op — single-axis, interleaved variant.

Parameters

aTensorImplPtr
Input tensor.
repsvector<int64_t>
Per-dimension repetition counts. Each entry must be >= 1. If reps.size() > a.rank(), leading size-1 axes are virtually prepended to the input.

Returns

TensorImplPtr

Tiled tensor with rank max(reps.size(), a.rank()) and out.shape[d] = a_padded.shape[d] * reps[d].

Notes

Backward sums the tiled gradient blocks via Dispatcher::tile_backward, which uses the padded input shape and the repetition counts to locate each contribution. Schema name "tile", AmpPolicy::KeepInput.

Examples

``tile_op([1, 2, 3], {2})`` produces ``[1, 2, 3, 1, 2, 3]``;
``tile_op([[1, 2]], {2, 3})`` produces a 2x6 tensor
``[[1, 2, 1, 2, 1, 2], [1, 2, 1, 2, 1, 2]]``.