mlx_broadcast_to() mirrors mlx.core.broadcast_to(),
repeating singleton dimensions without copying data.
Arguments
- x
An mlx array.
- shape
Integer vector describing the broadcasted shape.
- device
Execution target: supply
"gpu","cpu", or anmlx_streamcreated viamlx_new_stream(). Defaults to the currentmlx_default_device()unless noted otherwise (helpers that act on an existing array typically reuse that array's device or stream).
Examples
x <- mlx_matrix(1:3, nrow = 1)
broadcast <- mlx_broadcast_to(x, c(5, 3))
dim(broadcast)
#> [1] 5 3