broadcast_tensors

paddle. broadcast_tensors ( input, name=None ) [source]

Broadcast a list of tensors following broadcast semantics

Note

If you want know more about broadcasting, please refer to Introduction to Tensor .

Parameters
  • input (list|tuple) – input is a Tensor list or Tensor tuple which is with data type bool, float16, float32, float64, int32, int64, complex64, complex128. All the Tensors in input must have same data type. Currently we only support tensors with rank no greater than 5.

  • name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.

Returns

list(Tensor), The list of broadcasted tensors following the same order as input.

Examples

>>> import paddle
>>> x1 = paddle.rand([1, 2, 3, 4]).astype('float32')
>>> x2 = paddle.rand([1, 2, 1, 4]).astype('float32')
>>> x3 = paddle.rand([1, 1, 3, 1]).astype('float32')
>>> out1, out2, out3 = paddle.broadcast_tensors(input=[x1, x2, x3])
>>> # out1, out2, out3: tensors broadcasted from x1, x2, x3 with shape [1,2,3,4]