Skip to contents

mlx_cast() converts an mlx array to a different dtype without changing its shape.

Usage

mlx_cast(x, dtype = NULL)

Arguments

x

An mlx array.

dtype

Target dtype string. Defaults to the array's current dtype.

Value

An mlx array with the requested dtype.

See also

Examples

x <- mlx_vector(1:3, dtype = "int32")
mlx_cast(x, dtype = "float32")
#> mlx array [3]
#>   dtype: float32
#>   values:
#> [1] 1 2 3