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(). Default: mlx_default_device().

Value

A list of broadcast mlx arrays.

Examples

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