Skip to contents

Insert singleton dimensions

Usage

mlx_expand_dims(x, axes)

Arguments

x

An mlx array.

axes

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 <- mlx_matrix(1:4, 2, 2)
mlx_expand_dims(x, axes = 1)
#> mlx array [1 x 2 x 2]
#>   dtype: float32
#>   device: gpu
#>   (4 elements, not shown)