mlx_array() is a low-level constructor that skips as_mlx()'s type inference
and dimension guessing. Supply the raw payload vector plus an explicit shape
and it pipes the data straight into MLX.
Usage
mlx_array(
data,
dim,
dtype = NULL,
device = mlx_default_device(),
allow_scalar = FALSE
)Arguments
- data
Numeric, logical, or complex vector supplying the payload. Any dimension attributes are ignored; pass
dimexplicitly.- dim
Integer vector of array dimensions (product must equal
length(data)).- dtype
Optional MLX dtype. Defaults to
"float32"for numeric input,"bool"for logical, and"complex64"for complex.- device
Execution target: supply
"gpu","cpu", or anmlx_streamcreated viamlx_new_stream(). Defaults to the currentmlx_default_device()unless noted otherwise (helpers that act on an existing array typically reuse that array's device or stream).- allow_scalar
Logical; set
TRUEto permitdim = integer(0)so scalar payloads can be represented. When enabled,datamust be length 1 and the resulting array is dimensionless.