broadcast_shapes

broadcast_shapes(*shapes: Tuple[int | None, ...]) Tuple[int | None, ...]

Broadcasts one or more shapes against one another.

Parameters:

shapes (Tuple[Optional[int], ...]) – an arbitrary number of to-be broadcasted shapes.

Returns:

out (Tuple[Optional[int], …]) – a single broadcasted shape obtained by applying broadcasting rules (see Broadcasting) to each of the input shapes against one another.

Raises:

ValueError – If provided shapes which are not broadcast compatible (see Broadcasting), a ValueError should be raised.

Notes

  • If not provided one or more arguments, the function must return an empty tuple.

  • Array-conforming libraries which build computation graphs (e.g., ndonnx and Dask) and which need to provide a mechanism for indicating dimensions of unknown size may accept non-integer values (e.g., None). For these libraries, dimensions of unknown size must be propagated to the returned shape.