Skip to contents

mlx_broadcast_arrays() mirrors mlx.core.broadcast_arrays(), returning a list of inputs expanded to a common shape.

Usage

mlx_broadcast_arrays(..., device = NULL)

Arguments

...

One or more arrays (or a single list) convertible via as_mlx().

device

Execution target: supply "gpu", "cpu", or an mlx_stream created via mlx_new_stream(). Defaults to the current mlx_default_device() unless noted otherwise (helpers that act on an existing array typically reuse that array's device or stream).

Value

A list of broadcast mlx arrays.

Examples

a <- mlx_matrix(1:3, nrow = 1)
b <- mlx_matrix(1:3, ncol = 1)
outs <- mlx_broadcast_arrays(a, b)
lapply(outs, dim)
#> [[1]]
#> [1] 3 3
#> 
#> [[2]]
#> [1] 3 3
#>