flopscope.numpy.broadcast_shapes
fnp.broadcast_shapes(*args)[flopscope source][numpy source]
Broadcast the input shapes into a single shape.
Adapted from NumPy docs np.broadcast_shapes
Cost
0
Flopscope Context
Compute broadcast shape from input shapes.
Learn more about broadcasting here.
Added in version 1.20.0.
Parameters
- *args:tuples of ints, or ints
The shapes to be broadcast against each other.
Returns
- :tuple
Broadcasted shape.
Raises
- :ValueError
If the shapes are not compatible and cannot be broadcast according to NumPy's broadcasting rules.
See also
Examples
>>> import flopscope.numpy as fnp
>>> flops.broadcast_shapes((1, 2), (3, 1), (3, 2))
(3, 2)>>> flops.broadcast_shapes((6, 7), (5, 6, 1), (7,), (5, 1, 7))
(5, 6, 7)