pub mod supported_ops;
pub use supported_ops::SUPPORTED_OPS;
pub mod vmath;
#[cfg(rlx_mlx_host)]
pub(crate) mod ffi {
pub use rlx_mlx_sys::ffi::*;
}
#[cfg(rlx_mlx_host)]
pub mod array;
#[cfg(rlx_mlx_host)]
pub mod ops;
#[cfg(rlx_mlx_host)]
pub mod attention_bwd;
#[cfg(rlx_mlx_host)]
pub mod lower;
#[cfg(rlx_mlx_host)]
pub(crate) mod sync;
#[cfg(rlx_mlx_host)]
pub mod backend;
#[cfg(rlx_mlx_host)]
pub mod config;
#[cfg(rlx_mlx_host)]
pub mod compiled;
#[cfg(rlx_mlx_host)]
pub mod calibrate;
#[cfg(rlx_mlx_host)]
pub mod op_registry;
#[cfg(rlx_mlx_host)]
pub mod splat;
#[cfg(rlx_mlx_host)]
pub mod batched_lu_kernel;
#[cfg(rlx_mlx_host)]
pub mod dequant_q1_0;
#[cfg(rlx_mlx_host)]
pub mod llada2_gate;
#[cfg(rlx_mlx_host)]
pub mod ms_deform_attn;
#[cfg(rlx_mlx_host)]
pub mod distributed;
#[cfg(rlx_mlx_host)]
pub use array::{Array, MlxError, eval, version};
#[cfg(rlx_mlx_host)]
pub use backend::MlxExecutable;
#[cfg(rlx_mlx_host)]
pub use compiled::CompiledFn;
#[cfg(rlx_mlx_host)]
pub use config::{
COMPILE_OUTPUT_CAP_ENV, DEFAULT_COMPILE_OUTPUT_CAP, MlxRuntimeConfig, compile_output_cap,
install_runtime_config, reload_runtime_config, reset_compile_output_cap, runtime_config,
set_compile_output_cap,
};
#[cfg(rlx_mlx_host)]
pub use distributed::MlxTransport;
#[cfg(rlx_mlx_host)]
pub use lower::MlxMode;
#[cfg(rlx_mlx_host)]
pub fn is_available() -> bool {
use std::sync::OnceLock;
static OK: OnceLock<bool> = OnceLock::new();
*OK.get_or_init(probe_one_kernel)
}
#[cfg(rlx_mlx_host)]
fn probe_one_kernel() -> bool {
use rlx_mlx_sys::ffi::{
MlxDtype, RLX_MLX_OK, mlx_array_t, rlx_mlx_array_free, rlx_mlx_array_from_data,
rlx_mlx_eval, rlx_mlx_op_add,
};
std::panic::catch_unwind(|| unsafe {
let dims: [std::ffi::c_int; 1] = [1];
let data: [std::ffi::c_float; 1] = [1.0];
let mut a: *mut mlx_array_t = std::ptr::null_mut();
if rlx_mlx_array_from_data(dims.as_ptr(), 1, data.as_ptr(), 1, MlxDtype::F32, &mut a)
!= RLX_MLX_OK
|| a.is_null()
{
return false;
}
let mut sum: *mut mlx_array_t = std::ptr::null_mut();
let added = rlx_mlx_op_add(a, a, &mut sum) == RLX_MLX_OK && !sum.is_null();
let ok = added && rlx_mlx_eval([sum].as_ptr(), 1) == RLX_MLX_OK;
if !sum.is_null() {
rlx_mlx_array_free(sum);
}
rlx_mlx_array_free(a);
ok
})
.unwrap_or(false)
}
#[cfg(not(rlx_mlx_host))]
pub fn is_available() -> bool {
false
}