You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: python/paddle/tensor/manipulation.py
+14
Original file line number
Diff line number
Diff line change
@@ -1544,6 +1544,20 @@ def broadcast_tensors(
1544
1544
1545
1545
.. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor
1546
1546
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].
0 commit comments