mlx.core.broadcast_shapes

mlx.core.broadcast_shapes#

broadcast_shapes(*shapes: Sequence[int]) Tuple[int]#

Broadcast shapes.

Returns the shape that results from broadcasting the supplied array shapes against each other.

参数:

*shapes (Sequence[int]) -- The shapes to broadcast.

返回:

The broadcasted shape.

返回类型:

tuple

抛出:

ValueError -- If the shapes cannot be broadcast.

示例

>>> mx.broadcast_shapes((1,), (3, 1))
(3, 1)
>>> mx.broadcast_shapes((6, 7), (5, 6, 1), (7,))
(5, 6, 7)
>>> mx.broadcast_shapes((5, 1, 4), (1, 3, 1))
(5, 3, 4)