mars.tensor.broadcast_to#
- mars.tensor.broadcast_to(tensor, shape)[源代码]#
Broadcast an tensor to a new shape.
- 参数
tensor (array_like) – The tensor to broadcast.
shape (tuple) – The shape of the desired array.
- 返回
broadcast
- 返回类型
Tensor
- 引发
ValueError – If the tensor is not compatible with the new shape according to Mars’s broadcasting rules.
实际案例
>>> 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]])