broadcast_shapes(*shapes) → Size¶
The interface is consistent with PyTorch. The documentation is referenced from: https://pytorch.org/docs/1.10/generated/torch.broadcast_shapes.html.
oneflow.broadcast_tensors()but for shapes.
This is equivalent to
flow.broadcast_tensors(*map(flow.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.
*shapes (flow.Size) – Shapes of tensors.
A shape compatible with all input shapes.
RuntimeError – If shapes are incompatible.
>>> import oneflow as flow >>> flow.broadcast_shapes((2,), (3, 1), (1, 1, 1)) oneflow.Size([1, 3, 2])