maxframe.tensor.broadcast_to#

maxframe.tensor.broadcast_to(tensor, shape)[源代码]#

将张量广播到新的形状。

参数:
  • tensor (array_like) -- 要广播的张量。

  • shape (tuple) -- 目标数组的形状。

返回:

广播

返回类型:

Tensor

抛出:

ValueError -- 如果根据 MaxFrame 的广播规则,该张量与新形状不兼容。

示例

>>> 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]])