Skip to contents

as_r() mirrors base R coercion rules: MLX objects with dim() equal to NULL return a plain vector, while higher-dimensional inputs return matrices or arrays.

Usage

as_r(x, ...)

Arguments

x

An mlx array.

...

Additional arguments; ignored.

Value

A vector, matrix, or array depending on the dimensions of x.

Details

MLX does not support float64 operations on GPU. When this function creates a float64 array or converts one back to R, Rmlx temporarily switches only that internal creation or layout work to CPU. Later operations on the returned array still use the current mlx_device().

Examples

v <- as_mlx(1:3)
as_r(v)      # numeric vector
#> [1] 1 2 3