Skip to contents

Insert singleton dimensions

Usage

mlx_expand_dims(x, axis)

Arguments

x

An mlx array.

axis

Integer vector of axis positions (1-indexed) where new singleton dimensions should be inserted.

Value

An mlx array with additional dimensions of length one.

Examples

x <- as_mlx(matrix(1:4, 2, 2))
mlx_expand_dims(x, axis = 1)
#> mlx array [1 x 2 x 2]
#>   dtype: float32
#>   device: gpu
#>   (4 elements, not shown)