Skip to contents

mlx_broadcast_to() mirrors mlx.core.broadcast_to(), repeating singleton dimensions without copying data.

Usage

mlx_broadcast_to(x, shape, device = NULL)

Arguments

x

An mlx array.

shape

Integer vector describing the broadcasted shape.

device

Execution target: supply "gpu", "cpu", or an mlx_stream created via mlx_new_stream(). Default: mlx_default_device().

Value

An mlx array with the requested dimensions.

Examples

x <- as_mlx(matrix(1:3, nrow = 1))
broadcast <- mlx_broadcast_to(x, c(5, 3))
dim(broadcast)
#> [1] 5 3