broadcast_tensors

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

This OP broadcast a list of tensors following broadcast semantics

Note

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

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

  • name (str, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name.

Returns

The list of broadcasted tensors following the same order as input.

Return type

list(Tensor)

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]