Broadcasting
A rule in tensor operations that automatically expands tensors of different shapes so that element-wise computation can be performed. Broadcasting allows operations between arrays with compatible but non-identical dimensions by implicitly replicating data along size-one dimensions. Both PyTorch and NumPy support this mechanism, which removes the need for explicit shape replication and reduces memory overhead in numerical computation.
Timeline (last 90 days)
Broadcasting rules: starting from the trailing dimension (rightmost) and comparing dimension by dimension, if the two dimensions are equal or one of them is 1, they are considered compatible; when compatible, the dimension of size 1 is expanded to match the size of the other dimension. If a dimension is neither equal nor 1, an error is thrown.
Broadcasting does not actually allocate memory to copy data; instead it is implemented via a virtual expansion with a stride of 0, so it is efficient and saves GPU memory.
Broadcasting aligns dimensions from the trailing end, and dimensions of size 1 can be implicitly expanded to match the other operand without actually copying memory
All Facts (3)
Broadcasting rules: starting from the trailing dimension (rightmost) and comparing dimension by dimension, if the two dimensions are equal or one of them is 1, they are considered compatible; when compatible, the dimension of size 1 is expanded to match the size of the other dimension. If a dimension is neither equal nor 1, an error is thrown.
50%UnverifiedBroadcasting does not actually allocate memory to copy data; instead it is implemented via a virtual expansion with a stride of 0, so it is efficient and saves GPU memory.
50%UnverifiedBroadcasting aligns dimensions from the trailing end, and dimensions of size 1 can be implicitly expanded to match the other operand without actually copying memory
50%