Package: Rmlx 0.4.0

David Hugh-Jones

Rmlx: R Interface to MLX Arrays (GPU-Accelerated with Metal or CUDA)

S3 class 'mlx' backed by Apple's MLX library, allowing array operations on Apple Silicon GPUs/CPUs and CUDA-enabled Linux systems through lazy evaluation, shared memory between chips, and automatic differentiation.

Authors:David Hugh-Jones [aut, cre], Apple Inc. [cph]

Rmlx_0.4.0.tar.gz

Rmlx_0.4.0.tgz(r-4.6-arm64)
Rmlx_0.4.0.tar.gz(r-4.7-arm64)Rmlx_0.4.0.tar.gz(r-4.7-x86_64)Rmlx_0.4.0.tar.gz(r-4.6-arm64)Rmlx_0.4.0.tar.gz(r-4.6-x86_64)
manual.pdf |manual.html
card.svg |card.png
Rmlx/json (API)
NEWS

# Install 'Rmlx' in R:
install.packages('Rmlx', repos = c('https://community.r-multiverse.org', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/hughjonesd/rmlx/issues

Pkgdown/docs site:https://hughjonesd.github.io

Uses libs:
  • openblas– Optimized BLAS
  • c++– GNU Standard C++ Library v3

On CRAN:

Conda:

openblascpp

5.66 score 18 stars 13 scripts 209 exports 1 dependencies

Last updated from:3cbc7a9ee2 (on v0.4.0). Checks:5 OK, 1 WARNING, 7 FAIL. Indexed: no.

TargetResultTimeFilesSyslog
linux-devel-arm64OK440
linux-devel-x86_64OK442
source / vignettesOK818
linux-release-arm64OK403
linux-release-x86_64OK441
macos-release-arm64WARNING4693
macos-release-x86_64FAIL129
macos-oldrel-arm64FAIL74
macos-oldrel-x86_64FAIL146
windows-develFAIL68
windows-releaseFAIL79
windows-oldrelFAIL55
wasm-releaseFAIL114

Exports:abindas_mlxas_rasplitbacksolvechol2invcolcolMeanscolSumsdiagdropfftis_mlxkroneckerkronecker.defaultkronecker.mlxlocal_devicemlx_addmmmlx_allmlx_allclosemlx_anymlx_arangemlx_argmaxmlx_argminmlx_argpartitionmlx_argsortmlx_arraymlx_batch_normmlx_best_devicemlx_binary_cross_entropymlx_broadcast_arraysmlx_broadcast_tomlx_castmlx_cholesky_invmlx_clipmlx_compilemlx_conjugatemlx_contiguousmlx_conv_transpose1dmlx_conv_transpose2dmlx_conv_transpose3dmlx_conv1dmlx_conv2dmlx_conv3dmlx_coordinate_descentmlx_crossmlx_cross_entropymlx_cumprodmlx_cumsummlx_default_streammlx_degreesmlx_dequantizemlx_devicemlx_dexpmlx_diagonalmlx_disable_compilemlx_dlnormmlx_dlogismlx_dnormmlx_dropoutmlx_dtypemlx_dunifmlx_eigmlx_eighmlx_eigvalsmlx_eigvalshmlx_embeddingmlx_enable_compilemlx_erfmlx_erfinvmlx_evalmlx_expand_dimsmlx_eyemlx_fftmlx_fft2mlx_fftnmlx_flattenmlx_forwardmlx_fullmlx_gathermlx_gather_qmmmlx_gelumlx_gradmlx_hadamard_transformmlx_has_gpumlx_identitymlx_imagmlx_import_functionmlx_invmlx_isclosemlx_isfinitemlx_isinfmlx_isnanmlx_isneginfmlx_isposinfmlx_keymlx_key_bitsmlx_key_splitmlx_kronmlx_l1_lossmlx_layer_normmlx_leaky_relumlx_linearmlx_linspacemlx_loadmlx_load_ggufmlx_load_safetensorsmlx_logcumsumexpmlx_logsumexpmlx_lumlx_matrixmlx_maximummlx_meanmlx_meshgridmlx_metal_kernelmlx_minimummlx_moveaxismlx_mse_lossmlx_nan_to_nummlx_new_streammlx_normmlx_onesmlx_ones_likemlx_optimizer_sgdmlx_padmlx_param_set_valuesmlx_param_valuesmlx_parametersmlx_partitionmlx_pexpmlx_plnormmlx_plogismlx_pnormmlx_prodmlx_punifmlx_put_along_axismlx_qexpmlx_qlnormmlx_qlogismlx_qnormmlx_quantilemlx_quantizemlx_quantized_matmulmlx_qunifmlx_radiansmlx_rand_bernoullimlx_rand_categoricalmlx_rand_gumbelmlx_rand_laplacemlx_rand_multivariate_normalmlx_rand_normalmlx_rand_permutationmlx_rand_randintmlx_rand_truncated_normalmlx_rand_uniformmlx_realmlx_relumlx_repeatmlx_reshapemlx_rollmlx_savemlx_save_ggufmlx_save_safetensorsmlx_scalarmlx_scatter_add_axismlx_sdmlx_sequentialmlx_set_default_streammlx_set_trainingmlx_shapemlx_sigmoidmlx_silumlx_slice_updatemlx_softmaxmlx_softmax_layermlx_solve_triangularmlx_sortmlx_splitmlx_squeezemlx_stackmlx_stdmlx_stop_gradientmlx_summlx_swapaxesmlx_synchronizemlx_take_along_axismlx_tanhmlx_tilemlx_topkmlx_tracemlx_train_stepmlx_trimlx_tri_invmlx_trilmlx_triumlx_unflattenmlx_value_gradmlx_varmlx_vectormlx_wheremlx_zerosmlx_zeros_likeouterpinvrowrowMeansrowSumssvdwith_device

Dependencies:Rcpp

Getting Started with Rmlx

Rendered fromgetting-started.Rmdusingknitr::rmarkdownon May 26 2026.

Last update: 2026-05-13
Started: 2025-10-19

Linear Regression with MLX

Rendered fromlinear-regression.Rmdusingknitr::rmarkdownon May 26 2026.

Last update: 2026-05-12
Started: 2025-10-22

Neural Networks with Rmlx

Rendered fromneural-networks.Rmdusingknitr::rmarkdownon May 26 2026.

Last update: 2026-05-12
Started: 2025-10-23

Readme and manuals

Help Manual

Help pageTopics
Rmlx: R Interface to Apple's MLX ArraysRmlx-package Rmlx
Subset MLX arraymlx_subset [.mlx [<-.mlx
Matrix multiplication for MLX arrays%*%.mlx
Bind mlx arrays along an axisabind
Test if two MLX arrays are (nearly) equalall.equal.mlx
Create MLX array from R objectas_mlx
Convert MLX array to base R objectsas_r
Convert MLX array to R arrayas.array.mlx
Convert MLX array to R matrixas.matrix.mlx
Convert MLX array to R vectoras.double.mlx as.integer.mlx as.logical.mlx as.numeric.mlx as.vector.mlx
Split mlx arrays along a marginasplit asplit.default asplit.mlx
Column-bind mlx arrayscbind.mlx
Cholesky decomposition for mlx arrayschol.mlx
Inverse from Cholesky decompositionchol2inv chol2inv.default chol2inv.mlx
Column means for mlx arrayscolMeans colMeans.default colMeans.mlx
Column sums for mlx arrayscolSums colSums.default colSums.mlx
Cross productcrossprod.mlx
Diagonal matrix extraction and constructiondiag
Extract diagonal or construct diagonal matrix for mlx arraysdiag.mlx mlx_diagonal
Get dimensions of MLX arraydim.mlx mlx_shape
Set dimensions of MLX arraydim<-.mlx
Drop singleton dimensionsdrop drop.default drop.mlx
Fast Fourier Transformfft fft.default fft.mlx
Format method for mlx_streamformat.mlx_stream
Test if object is an MLX arrayis_mlx
Kronecker product dispatcherkronecker kronecker,ANY,mlx-method kronecker,mlx,ANY-method kronecker,mlx,mlx-method kronecker.default kronecker.mlx
Get length of MLX arraylength.mlx
Math operations for MLX arraysabs.mlx acos.mlx acosh.mlx asin.mlx asinh.mlx atan.mlx atanh.mlx ceiling.mlx cos.mlx cosh.mlx cospi.mlx cummax.mlx cummin.mlx cumprod.mlx cumsum.mlx exp.mlx expm1.mlx floor.mlx log.mlx log10.mlx log1p.mlx log2.mlx Math.mlx round.mlx sign.mlx signif.mlx sin.mlx sinh.mlx sinpi.mlx sqrt.mlx tan.mlx tanh.mlx tanpi.mlx trunc.mlx
Mean of MLX array elementsmean.mlx
Fused matrix multiply and add for MLX arraysmlx_addmm
Test if all elements of two arrays are closemlx_allclose
Numerical ranges on MLX devicesmlx_arange
Argmax and argmin on mlx arraysmlx_argmax mlx_argmin
Construct an MLX array from R datamlx_array
Batch normalizationmlx_batch_norm
Get best available devicemlx_best_device
Binary cross-entropy lossmlx_binary_cross_entropy
Broadcast multiple arrays to a shared shapemlx_broadcast_arrays
Broadcast an array to a new shapemlx_broadcast_to
Cast an mlx arraymlx_cast
Compute matrix inverse via Cholesky decompositionmlx_cholesky_inv
Clip mlx array values into a rangemlx_clip
Compile an MLX Function for Optimized Executionmlx_compile
Ensure contiguous memory layoutmlx_contiguous
1D Transposed Convolutionmlx_conv_transpose1d
2D Transposed Convolutionmlx_conv_transpose2d
3D Transposed Convolutionmlx_conv_transpose3d
1D Convolutionmlx_conv1d
2D Convolutionmlx_conv2d
3D Convolutionmlx_conv3d
Coordinate Descent with L1 Regularizationmlx_coordinate_descent
Vector cross product with mlx arraysmlx_cross
Cross-entropy lossmlx_cross_entropy
Cumulative sum and productmlx_cumprod mlx_cumsum
Convert between radians and degreesmlx_degrees mlx_radians
Dequantize a Matrixmlx_dequantize
Get or set current MLX devicemlx_device
Exponential distribution functionsmlx_dexp mlx_pexp mlx_qexp
Control Global Compilation Behaviormlx_disable_compile mlx_enable_compile
Lognormal distribution functionsmlx_dlnorm mlx_plnorm mlx_qlnorm
Logistic distribution functionsmlx_dlogis mlx_plogis mlx_qlogis
Normal distribution functionsmlx_dnorm mlx_pnorm mlx_qnorm
Dropout layermlx_dropout
Get the data type of an MLX arraymlx_dtype
Uniform distribution functionsmlx_dunif mlx_punif mlx_qunif
Eigen decomposition for mlx arraysmlx_eig
Eigen decomposition of Hermitian mlx arraysmlx_eigh
Eigenvalues of mlx arraysmlx_eigvals
Eigenvalues of Hermitian mlx arraysmlx_eigvalsh
Embedding layermlx_embedding
Error function and inverse error functionmlx_erf mlx_erfinv
Force evaluation of an MLX operationsmlx_eval
Insert singleton dimensionsmlx_expand_dims
Identity-like matrices on MLX devicesmlx_eye
Fast Fourier transforms for MLX arraysmlx_fft mlx_fft2 mlx_fftn
Flatten axes of an mlx arraymlx_flatten
Forward pass utilitymlx_forward
Fill an mlx array with a constant valuemlx_full
Gather elements from an mlx arraymlx_gather
Gather-based Quantized Matrix Multiplicationmlx_gather_qmm
GELU activationmlx_gelu
Automatic differentiation for MLX functionsmlx_grad mlx_value_grad
Hadamard transform for MLX arraysmlx_hadamard_transform
Check if GPU backend is availablemlx_has_gpu
Identity matrices on MLX devicesmlx_identity
Import an exported MLX functionmlx_import_function
Compute matrix inversemlx_inv
Element-wise approximate equalitymlx_isclose
Elementwise NaN and infinity predicatesmlx_isfinite mlx_isinf mlx_isnan
Detect signed infinities in mlx arraysmlx_isneginf mlx_isposinf
Construct MLX random number generator keysmlx_key mlx_key_split
Generate raw random bits on MLX arraysmlx_key_bits
Kronecker product for mlx arraysmlx_kron
L1 loss (Mean Absolute Error)mlx_l1_loss
Layer normalizationmlx_layer_norm
Leaky ReLU activationmlx_leaky_relu
Create a learnable linear transformationmlx_linear
Evenly spaced ranges on MLX devicesmlx_linspace
Load an MLX array from diskmlx_load
Load MLX tensors from the GGUF formatmlx_load_gguf
Load MLX arrays from the safetensors formatmlx_load_safetensors
Log cumulative sum exponential for mlx arraysmlx_logcumsumexp
Log-sum-exp reduction for mlx arraysmlx_logsumexp
LU factorizationmlx_lu
Construct MLX matrices efficientlymlx_matrix
Elementwise maximum of two mlx arraysmlx_maximum
Construct coordinate arrays from input vectorsmlx_meshgrid
Create a JIT-compiled custom Metal kernelmlx_metal_kernel
Elementwise minimum of two mlx arraysmlx_minimum
Reorder mlx array axesaperm.mlx mlx_moveaxis
Mean squared error lossmlx_mse_loss
Replace NaN and infinite values with finite numbersmlx_nan_to_num
MLX streams for asynchronous executionmlx_default_stream mlx_new_stream
Matrix and vector norms for mlx arraysmlx_norm
Create arrays of ones on MLX devicesmlx_ones
Ones shaped like an existing mlx arraymlx_ones_like
Stochastic gradient descent optimizermlx_optimizer_sgd
Pad mlx arraysmlx_pad
Assign arrays back to parametersmlx_param_set_values
Retrieve parameter arraysmlx_param_values
Collect parameters from modulesmlx_parameters
Write values using per-position axis indicesmlx_put_along_axis
Compute quantiles of MLX arraysmlx_quantile quantile.mlx
Quantize a Matrixmlx_quantize
Quantized Matrix Multiplicationmlx_quantized_matmul
Sample Bernoulli random variables on mlx arraysmlx_rand_bernoulli
Sample from a categorical distribution on mlx arraysmlx_rand_categorical
Sample from the Gumbel distribution on mlx arraysmlx_rand_gumbel
Sample from the Laplace distribution on mlx arraysmlx_rand_laplace
Sample from a multivariate normal distribution on mlx arraysmlx_rand_multivariate_normal
Sample from a normal distribution on mlx arraysmlx_rand_normal
Generate random permutations on mlx arraysmlx_rand_permutation
Sample random integers on mlx arraysmlx_rand_randint
Sample from a truncated normal distribution on mlx arraysmlx_rand_truncated_normal
Sample from a uniform distribution on mlx arraysmlx_rand_uniform
Complex-valued helpers for mlx arraysmlx_conjugate mlx_imag mlx_real
Rectified linear activation modulemlx_relu
Repeat array elementsmlx_repeat
Reshape an mlx arraymlx_reshape
Roll array elementsmlx_roll
Save an MLX array to diskmlx_save
Save MLX arrays to the GGUF formatmlx_save_gguf
Save MLX arrays to the safetensors formatmlx_save_safetensors
Construct MLX scalarsmlx_scalar
Add values using per-position axis indicesmlx_scatter_add_axis
Compose modules sequentiallymlx_sequential
Set the default MLX streammlx_set_default_stream
Toggle training mode for MLX modulesmlx_set_training
Sigmoid activationmlx_sigmoid
SiLU (Swish) activationmlx_silu
Update a slice of an mlx arraymlx_slice_update
Softmax for mlx arraysmlx_softmax
Softmax activationmlx_softmax_layer
Solve triangular systems with mlx arraysbacksolve backsolve.default backsolve.mlx mlx_solve_triangular
Sort and argsort for mlx arraysmlx_argsort mlx_sort
Split mlx arraysmlx_split
Remove singleton dimensionsmlx_squeeze
Stack mlx arrays along a new axismlx_stack
Stop gradient propagation through an mlx arraymlx_stop_gradient
Reduce mlx arraysmlx_all mlx_any mlx_mean mlx_prod mlx_sd mlx_std mlx_sum mlx_var
Swap two axes of an mlx arraymlx_swapaxes
Synchronize MLX executionmlx_synchronize
Take values using per-position axis indicesmlx_take_along_axis
Tanh activationmlx_tanh
Tile an arraymlx_tile
Top-k selection and partitioning on mlx arraysmlx_argpartition mlx_partition mlx_topk
Matrix trace for mlx arraysmlx_trace
Single training step helpermlx_train_step
Triangular helpers for MLX arraysmlx_tri mlx_tril mlx_triu
Compute triangular matrix inversemlx_tri_inv
Unflatten an axis into multiple axesmlx_unflatten
Construct MLX vectorsmlx_vector
Elementwise conditional selectionmlx_where
Create arrays of zeros on MLX devicesmlx_zeros
Zeros shaped like an existing mlx arraymlx_zeros_like
Dimnames and names for MLX arraysdimnames.mlx dimnames<-.mlx mlx-dimnames names.mlx names<-.mlx
Base R generics with mlx methodsmlx-methods
Arithmetic and comparison operators for MLX arrays!.mlx !=.mlx %%.mlx %/%.mlx &.mlx *.mlx +.mlx -.mlx /.mlx <.mlx <=.mlx ==.mlx >.mlx >=.mlx Ops.mlx ^.mlx |.mlx
Outer product of two vectorsouter outer.mlx
Moore-Penrose pseudoinverse for MLX arrayspinv
Print MLX arrayprint.mlx
Print method for mlx_streamprint.mlx_stream
QR decomposition for mlx arraysqr.mlx
Row-bind mlx arraysrbind.mlx
Row and column indices for mlx arrayscol col.default col.mlx row row.default row.mlx
Row means for mlx arraysrowMeans rowMeans.default rowMeans.mlx
Row sums for mlx arraysrowSums rowSums.default rowSums.mlx
Scale mlx arraysscale.mlx
Solve a system of linear equationssolve.mlx
Object structure for MLX arraystr.mlx
Summary operations for MLX arraysall.mlx any.mlx max.mlx min.mlx prod.mlx sum.mlx Summary.mlx
Singular value decompositionsvd
Singular value decomposition for mlx arrayssvd.mlx
Transpose of MLX matrixt.mlx
Transposed cross producttcrossprod.mlx
Temporarily set the current MLX device or streamlocal_device with_device