is_broadcastable

is_broadcastable(shp1: tuple[int, ...], shp2: tuple[int, ...])[source][source]

Check if two shapes are broadcastable.

Parameters:
  • shp1 (tuple[int, ]) – The first shape.

  • shp2 (tuple[int, ]) – The second shape.

Return type:

bool

Examples

>>> is_broadcastable((2, 3), (2, 3))
True
>>> is_broadcastable((2, 3), (3, 2))
False
>>> is_broadcastable((2, 3), (2, 1))
True