dpctl.tensor.repeat(x, repeats, axis=None)[source]

Repeat elements of an array on a per-element basis.

  • x (usm_ndarray) – input array

  • repeats (Union[int, Sequence[int, ...], usm_ndarray]) –

    The number of repetitions for each element.

    repeats must be broadcast-compatible with N where N is prod(x.shape) if axis is None and x.shape[axis] otherwise.

    If repeats is an array, it must have an integer data type. Otherwise, repeats must be a Python integer or sequence of Python integers (i.e., a tuple, list, or range).

  • axis (Optional[int]) – The axis along which to repeat values. If axis is None, the function repeats elements of the flattened array. Default: None.


output array with repeated elements.

If axis is None, the returned array is one-dimensional, otherwise, it has the same shape as x, except for the axis along which elements were repeated.

The returned array will have the same data type as x. The returned array will be located on the same device as x and have the same USM allocation type as x.

Return type:



AxisError – if axis value is invalid.