maxframe.tensor.broadcast_to#

maxframe.tensor.broadcast_to(tensor, shape)[source]#

Broadcast a 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 MaxFrame’s broadcasting rules.

Examples

>>> import maxframe.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]])