mars.tensor.broadcast_to#
- mars.tensor.broadcast_to(tensor, shape)[source]#
Broadcast an tensor to a new shape.
- Parameters
tensor (array_like) – The tensor to broadcast.
shape (tuple) – The shape of the desired array.
- Returns
broadcast
- Return type
Tensor
- Raises
ValueError – If the tensor is not compatible with the new shape according to Mars’s broadcasting rules.
Examples
>>> import mars.tensor as mt
>>> x = mt.array([1, 2, 3]) >>> mt.broadcast_to(x, (3, 3)).execute() array([[1, 2, 3], [1, 2, 3], [1, 2, 3]])