Skip to contents

Returns a copy of x with contiguous strides on the requested device or stream.

Usage

mlx_contiguous(x, device = NULL)

Arguments

x

An mlx array.

device

Execution target: supply "gpu", "cpu", or an mlx_stream created via mlx_new_stream(). Default: mlx_default_device().

Value

An mlx array backed by contiguous storage on the specified device.

Examples

x <- mlx_swapaxes(as_mlx(matrix(1:4, 2, 2)), axis1 = 1, axis2 = 2)
y <- mlx_contiguous(x)
identical(as.array(x), as.array(y))
#> [1] TRUE