Skip to contents

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

Usage

mlx_broadcast_to(x, shape)

Arguments

x

An mlx array.

shape

Integer vector describing the broadcasted shape.

Value

An mlx array with the requested dimensions. Dimnames from matching or singleton broadcast axes are carried to the result.

Examples

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