megengine.functional.repeat#

repeat(inp, repeats, axis=None)[source]#

Repeat elements of an array.

Parameters:
  • inp (Tensor) – input tensor.

  • repeats (int) – the number of repetitions for each element.

  • axis (Optional[int]) – the axis along which to repeat values. By default, use the flattened input array, and return a flat output array.

Returns:

output tensor.

Examples

>>> import numpy as np
>>> x = Tensor([[1, 2], [3, 4]], np.int32)
>>> F.repeat(x, 2, axis=0)
Tensor([[1 2]
 [1 2]
 [3 4]
 [3 4]], dtype=int32, device=xpux:0)