broadcast_shapes turns a 0 dimension into 1
Author: SashaMITCreated Sep 30, 2026Updated Sep 30, 2026
broadcast_shapes([(0,), (1,)]) returns (1,). NumPy returns (0,). broadcast_shapes([(5, 1), (1, 0)]) returns (5, 1). NumPy returns (5, 0). broadcast_shapes([(1, 0), (0, 1)]) returns (1, 1). NumPy returns (0, 0).
The function follows NumPy, and wp.map uses this shape for the output array. When one size is 1, the result is max of the two sizes, so 0 loses to 1. broadcast_shapes([(3, 1, 4), (5, 4)]) is still (3, 5, 4).
Source: NVIDIA/warp