vainaijr:


If the number of dimensions of x and y are not equal, prepend 1 to the dimensions of the tensor with fewer dimensions to make them equal length.



We can also take a look at the numpy broadcast rules 1, that state:

they are equal, or
one of them is 1

2 conditions satisfied in your example
>>> x_np = np.random.rand(4,1,0)
>>> y_np = np.random.rand(4,1,1)
>>> x_np + y_np
array([], shape=(4, 1, 0), dtype=float64)

dim of 0 is a special case, that will make your tensor volume to be 0.
Apparently, in is considered to be “bigger” than 1 in broadcasting. So the resulting dim is 0*1=0