asc.experimental.asctile.broadcast_shapes
- asc.experimental.asctile.broadcast_shapes(*shapes: Iterable[int]) Tuple[int, ...]
Compute the common shape that all input shapes can be broadcast to.
This function applies broadcasting rules to determine the smallest shape that is compatible with all provided shapes. Shorter shapes are padded with 1s on the left, then dimensions are compared element-wise, and each dimension must either match or be of size 1.
- Parameters:
shapes – Variable number of shapes (each shape is an iterable of integers)
- Returns:
The common broadcast shape
- Return type:
Tuple[int, …]
- Raises:
ValueError – If no shapes are provided
RuntimeError – If the shapes are incompatible and cannot be broadcast together
Examples
Compute common shape for multiple shapes:
common = broadcast_shapes([256], [16, 256]) # returns (16, 256) common = broadcast_shapes([1, 256], [16, 1]) # returns (16, 256)