mindspore.ops.repeat_interleave

mindspore.ops.repeat_interleave(input, repeats, axis=None)[source]

Repeat elements of a tensor along an axis, like numpy.repeat.

Parameters
  • input (Tensor) – The tensor to repeat values for. Must be of type: float16, float32, int8, uint8, int16, int32, or int64.

  • repeats (Union[int, tuple, list, Tensor]) – The number of times to repeat, must be positive.

  • axis (int, optional) – The axis along which to repeat, Default: None. if dims is None, the input Tensor will be flattened and the output will alse be flattened.

Returns

One tensor with values repeated along the specified axis. If input has shape \((s1, s2, ..., sn)\) and axis is i, the output will have shape \((s1, s2, ..., si * repeats, ..., sn)\). The output type will be the same as the type of input.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> input = Tensor(np.array([[0, 1, 2], [3, 4, 5]]), mindspore.int32)
>>> output = ops.repeat_interleave(input, repeats=2, axis=0)
>>> print(output)
[[0 1 2]
 [0 1 2]
 [3 4 5]
 [3 4 5]]