broadcast_shape

paddle. broadcast_shape ( x_shape, y_shape ) [源代码]

该函数返回对x_shape大小的张量和y_shape大小的张量做broadcast操作后得到的shape,如您想了解更多,请参见 广播 (broadcasting)

参数

  • x_shape (list[int]|tuple[int]) - 输入Tensor的shape。

  • y_shape (list[int]|tuple[int]) - 输入Tensor的shape。

返回

broadcast操作后的shape,返回类型为 list[int]。

代码示例

import paddle

shape = paddle.broadcast_shape([2, 1, 3], [1, 3, 1])
# [2, 3, 3]

# shape = paddle.broadcast_shape([2, 1, 3], [3, 3, 1])
# ValueError (terminated with error message).