Skip to content

Commit 279fa69

Browse files
authored
[Docathon][Add API Legend No.2] (#69266)
1 parent ae67aa4 commit 279fa69

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

python/paddle/tensor/manipulation.py

+14
Original file line numberDiff line numberDiff line change
@@ -1544,6 +1544,20 @@ def broadcast_tensors(
15441544
15451545
.. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor
15461546
1547+
The following figure illustrates the process of broadcasting three tensors to the same dimensions.
1548+
The dimensions of the three tensors are [4, 1, 3], [2, 3], and [4, 2, 1], respectively. During broadcasting,
1549+
alignment starts from the last dimension, and for each dimension, either the sizes of the two tensors in that dimension are equal,
1550+
or one of the tensors has a dimension of 1, or one of the tensors lacks that dimension. In the figure below, in the last dimension,
1551+
Tensor3 has a size of 1, while Tensor1 and Tensor2 have sizes of 3; thus, this dimension is expanded to 3 for all tensors.
1552+
In the second-to-last dimension, Tensor1 has a size of 2, and Tensor2 and Tensor3 both have sizes of 2; hence, this dimension is expanded to 2 for all tensors.
1553+
In the third-to-last dimension, Tensor2 lacks this dimension, while Tensor1 and Tensor3 have sizes of 4; consequently,
1554+
this dimension is expanded to 4 for all tensors. Ultimately, all tensors are expanded to [4, 2, 3].
1555+
1556+
.. image:: https://githubraw.cdn.bcebos.com/PaddlePaddle/docs/develop/docs/images/api_legend/broadcast.png
1557+
:width: 800
1558+
:alt: Illustration of BroadCast
1559+
:align: center
1560+
15471561
Args:
15481562
input (list|tuple): ``input`` is a Tensor list or Tensor tuple which is with data type bool,
15491563
float16, float32, float64, int32, int64, complex64, complex128. All the Tensors in ``input`` must have same data type.

0 commit comments

Comments
 (0)