Shape Utils

Shape Utils#

Broadcasting and shape manipulation utilities.

nabla.utils.shape_utils.get_broadcasted_shape(shape1, shape2, ignore_axes=None, replace_ignored_dims=None)[source]#

Compute the broadcasted shape of two input shapes.

Parameters:
  • shape1 (tuple[int, ...]) – First input shape

  • shape2 (tuple[int, ...]) – Second input shape

  • ignore_axes (list[int] | None) – Axes to ignore during broadcasting

  • replace_ignored_dims (list[int] | None) – Replacement dimensions for ignored axes

Returns:

The broadcasted output shape

Raises:

ValueError – If shapes cannot be broadcast together

Return type:

tuple[int, …]