Skip to contents

mlx_zeros_like() mirrors mlx.core.zeros_like(): it creates a zero-filled array matching the source array's shape. Optionally override the dtype or device.

Usage

mlx_zeros_like(x, dtype = NULL, device = NULL)

Arguments

x

An mlx array.

dtype

Optional MLX dtype override. Defaults to the source array's dtype.

device

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

Value

An mlx array of zeros matching x.

Examples

base <- mlx_ones(c(2, 2))
zeros <- mlx_zeros_like(base)
as.matrix(zeros)
#>      [,1] [,2]
#> [1,]    0    0
#> [2,]    0    0