broadcast_shapes(*shapes) → Size¶
broadcast_tensors()but for shapes.
This is equivalent to
torch.broadcast_tensors(*map(torch.empty, shapes)).shapebut avoids the need create to intermediate tensors. This is useful for broadcasting tensors of common batch shape but different rightmost shape, e.g. to broadcast mean vectors with covariance matrices.
>>> torch.broadcast_shapes((2,), (3, 1), (1, 1, 1)) torch.Size([1, 3, 2])
*shapes (torch.Size) – Shapes of tensors.
A shape compatible with all input shapes.
- Return type
RuntimeError – If shapes are incompatible.