tilus.Script.repeat_interleave

tilus.Script.repeat_interleave

Script.repeat_interleave(x, repeats, *, out=None)[source]

Repeat elements of a register tensor along its dimensions.

This instruction repeats each element of the register tensor x according to the repeats parameter. The repeats parameter is a sequence of integers, where each integer specifies how many times to repeat the corresponding element of x.

The difference between repeat() and repeat_interleave() is similar to the torch.Tensor.repeat function vs. torch.Tensor.repeat_interleave.

Use one dimension tensor as an example:

a = [1, 2, 3]
repeat(a, [2])  # Output: [1, 2, 3, 1, 2, 3]
repeat_interleave(a, [2])  # Output: [1, 1, 2, 2, 3, 3]
Parameters:
  • x (RegisterTensor) – The register tensor to repeat.

  • repeats (Sequence[int]) – The number of times to repeat each element of x. If the length of repeats is less than the number of dimensions of x, it will be padded with 1s for the beginning dimensions. If it is longer, we will expand the x tensor with 1s in the beginning dimensions to match the length of repeats.

  • out (RegisterTensor, optional) – The register tensor to store the result. If not provided, a new register tensor will be allocated.

Returns:

ret – The register tensor containing the repeated elements of x. The shape of the output tensor will be determined by the repeats parameter, and its dtype will be the same as that of x.

Return type:

RegisterTensor