[package]
edition = "2024"
rust-version = "1.95"
name = "mlxrs"
version = "0.1.0"
build = "build.rs"
autolib = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "Safe Rust bindings for Apple's MLX array framework, with LM, VLM, audio, and embeddings support"
homepage = "https://github.com/fintit-ai/mlxrs"
documentation = "https://docs.rs/mlxrs"
readme = "README.md"
keywords = [
"mlx",
"apple-silicon",
"machine-learning",
"metal",
"llm",
]
categories = [
"science",
"api-bindings",
"external-ffi-bindings",
"mathematics",
]
license = "MIT OR Apache-2.0"
repository = "https://github.com/fintit-ai/mlxrs"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = [
"--cfg",
"docsrs",
]
[features]
audio = [
"lm",
"dep:symphonia",
"dep:cpal",
"dep:unicode-normalization",
"dep:xattr",
]
default = []
embeddings = [
"tokenizer",
"dep:memspan",
"dep:glob",
]
gguf = []
llguidance = [
"lm",
"dep:llguidance",
"dep:toktrie_hf_tokenizers",
"dep:serde_json",
]
lm = [
"tokenizer-config",
"tokenizer-stream",
"tokenizer-spm",
"tokenizer-bpe",
"tokenizer-chat",
"tokenizer-deepseek-v32",
"tokenizer-tools",
"dep:regex",
]
tokenizer = ["dep:tokenizers"]
tokenizer-bpe = [
"tokenizer-stream",
"tokenizer-gpt2",
"dep:serde_json",
]
tokenizer-chat = [
"tokenizer-config",
"dep:minijinja",
"dep:minijinja-contrib",
"dep:serde",
"dep:jiff",
]
tokenizer-config = [
"tokenizer",
"dep:serde_json",
]
tokenizer-deepseek-v32 = ["tokenizer-chat"]
tokenizer-gpt2 = []
tokenizer-spm = [
"tokenizer-stream",
"dep:serde_json",
]
tokenizer-stream = ["tokenizer"]
tokenizer-tools = [
"tokenizer-config",
"dep:serde_json",
]
unstable-ops-overload = []
vlm = [
"lm",
"dep:image",
]
[lib]
name = "mlxrs"
path = "src/lib.rs"
[[test]]
name = "archetypes"
path = "tests/archetypes.rs"
[[test]]
name = "array_construction"
path = "tests/array_construction.rs"
[[test]]
name = "array_conversion"
path = "tests/array_conversion.rs"
[[test]]
name = "array_explicit_eval"
path = "tests/array_explicit_eval.rs"
[[test]]
name = "audio_dsp"
path = "tests/audio_dsp.rs"
[[test]]
name = "audio_g2p"
path = "tests/audio_g2p.rs"
[[test]]
name = "audio_io"
path = "tests/audio_io.rs"
[[test]]
name = "audio_playback"
path = "tests/audio_playback.rs"
[[test]]
name = "audio_streaming_stt"
path = "tests/audio_streaming_stt.rs"
[[test]]
name = "audio_sts_pipeline"
path = "tests/audio_sts_pipeline.rs"
[[test]]
name = "audio_stt"
path = "tests/audio_stt.rs"
[[test]]
name = "audio_stt_serializers"
path = "tests/audio_stt_serializers.rs"
[[test]]
name = "audio_tts"
path = "tests/audio_tts.rs"
[[test]]
name = "audit_safety_tests"
path = "tests/audit_safety_tests.rs"
[[test]]
name = "diagnostics"
path = "tests/diagnostics.rs"
[[test]]
name = "element_extended"
path = "tests/element_extended.rs"
[[test]]
name = "embeddings"
path = "tests/embeddings.rs"
[[test]]
name = "embeddings_load"
path = "tests/embeddings_load.rs"
[[test]]
name = "error_paths"
path = "tests/error_paths.rs"
[[test]]
name = "io"
path = "tests/io.rs"
[[test]]
name = "kv_cache_from_serialized"
path = "tests/kv_cache_from_serialized.rs"
[[test]]
name = "lm_cache"
path = "tests/lm_cache.rs"
[[test]]
name = "lm_cache_arrays"
path = "tests/lm_cache_arrays.rs"
[[test]]
name = "lm_cache_batch"
path = "tests/lm_cache_batch.rs"
[[test]]
name = "lm_cache_cache_list"
path = "tests/lm_cache_cache_list.rs"
[[test]]
name = "lm_cache_chunked"
path = "tests/lm_cache_chunked.rs"
[[test]]
name = "lm_cache_invariant_regressions"
path = "tests/lm_cache_invariant_regressions.rs"
[[test]]
name = "lm_cache_persist"
path = "tests/lm_cache_persist.rs"
[[test]]
name = "lm_cache_prompt"
path = "tests/lm_cache_prompt.rs"
[[test]]
name = "lm_cache_prompt_driver"
path = "tests/lm_cache_prompt_driver.rs"
[[test]]
name = "lm_cache_quantized"
path = "tests/lm_cache_quantized.rs"
[[test]]
name = "lm_cache_reference_class_name"
path = "tests/lm_cache_reference_class_name.rs"
[[test]]
name = "lm_convert"
path = "tests/lm_convert.rs"
[[test]]
name = "lm_fuse"
path = "tests/lm_fuse.rs"
[[test]]
name = "lm_generate"
path = "tests/lm_generate.rs"
[[test]]
name = "lm_load"
path = "tests/lm_load.rs"
[[test]]
name = "lm_sample"
path = "tests/lm_sample.rs"
[[test]]
name = "lm_speculative"
path = "tests/lm_speculative.rs"
[[test]]
name = "lm_structured"
path = "tests/lm_structured.rs"
[[test]]
name = "lm_tool_parsers"
path = "tests/lm_tool_parsers.rs"
[[test]]
name = "losses"
path = "tests/losses.rs"
[[test]]
name = "memory"
path = "tests/memory.rs"
[[test]]
name = "memory_wired"
path = "tests/memory_wired.rs"
[[test]]
name = "ops_arithmetic"
path = "tests/ops_arithmetic.rs"
[[test]]
name = "ops_comparison"
path = "tests/ops_comparison.rs"
[[test]]
name = "ops_fast_metal_kernel"
path = "tests/ops_fast_metal_kernel.rs"
[[test]]
name = "ops_fft"
path = "tests/ops_fft.rs"
[[test]]
name = "ops_indexing"
path = "tests/ops_indexing.rs"
[[test]]
name = "ops_linalg_basic"
path = "tests/ops_linalg_basic.rs"
[[test]]
name = "ops_linalg_full"
path = "tests/ops_linalg_full.rs"
[[test]]
name = "ops_logical"
path = "tests/ops_logical.rs"
[[test]]
name = "ops_misc"
path = "tests/ops_misc.rs"
[[test]]
name = "ops_quantized"
path = "tests/ops_quantized.rs"
[[test]]
name = "ops_random"
path = "tests/ops_random.rs"
[[test]]
name = "ops_reduction"
path = "tests/ops_reduction.rs"
[[test]]
name = "ops_shape"
path = "tests/ops_shape.rs"
[[test]]
name = "ops_tail"
path = "tests/ops_tail.rs"
[[test]]
name = "ops_traits_by_value"
path = "tests/ops_traits_by_value.rs"
[[test]]
name = "perf_floor"
path = "tests/perf_floor.rs"
[[test]]
name = "smoke"
path = "tests/smoke.rs"
[[test]]
name = "stream_device"
path = "tests/stream_device.rs"
[[test]]
name = "stripped_ctor_constructors"
path = "tests/stripped_ctor_constructors.rs"
[[test]]
name = "stripped_ctor_try_item"
path = "tests/stripped_ctor_try_item.rs"
[[test]]
name = "thread_safety"
path = "tests/thread_safety.rs"
[[test]]
name = "tokenizer"
path = "tests/tokenizer.rs"
[[test]]
name = "tokenizer_adversarial"
path = "tests/tokenizer_adversarial.rs"
[[test]]
name = "tokenizer_chat_hf_extensions"
path = "tests/tokenizer_chat_hf_extensions.rs"
[[test]]
name = "tokenizer_chat_parity"
path = "tests/tokenizer_chat_parity.rs"
[[test]]
name = "tokenizer_chat_tojson"
path = "tests/tokenizer_chat_tojson.rs"
[[test]]
name = "tokenizer_core"
path = "tests/tokenizer_core.rs"
[[test]]
name = "tokenizer_encode_options"
path = "tests/tokenizer_encode_options.rs"
[[test]]
name = "tokenizer_sentencepiece"
path = "tests/tokenizer_sentencepiece.rs"
[[test]]
name = "tokenizer_stream_correctness"
path = "tests/tokenizer_stream_correctness.rs"
[[test]]
name = "tokenizer_swift"
path = "tests/tokenizer_swift.rs"
[[test]]
name = "tokenizer_wrapper"
path = "tests/tokenizer_wrapper.rs"
[[test]]
name = "transforms"
path = "tests/transforms.rs"
[[test]]
name = "transforms_async_eval"
path = "tests/transforms_async_eval.rs"
[[test]]
name = "vlm_feature_cache"
path = "tests/vlm_feature_cache.rs"
[[test]]
name = "vlm_generate"
path = "tests/vlm_generate.rs"
[[test]]
name = "vlm_image"
path = "tests/vlm_image.rs"
[[test]]
name = "vlm_inputs"
path = "tests/vlm_inputs.rs"
[[test]]
name = "vlm_prompt"
path = "tests/vlm_prompt.rs"
[[test]]
name = "vlm_video"
path = "tests/vlm_video.rs"
[[bench]]
name = "arithmetic"
path = "benches/arithmetic.rs"
harness = false
[[bench]]
name = "linalg"
path = "benches/linalg.rs"
harness = false
[[bench]]
name = "reduction"
path = "benches/reduction.rs"
harness = false
[[bench]]
name = "shape"
path = "benches/shape.rs"
harness = false
[[bench]]
name = "simd_bgr_widen"
path = "benches/simd_bgr_widen.rs"
harness = false
required-features = ["vlm"]
[[bench]]
name = "simd_lfilter"
path = "benches/simd_lfilter.rs"
harness = false
required-features = ["audio"]
[[bench]]
name = "simd_pad_canvas_fill"
path = "benches/simd_pad_canvas_fill.rs"
harness = false
required-features = ["vlm"]
[[bench]]
name = "simd_pcm_decode"
path = "benches/simd_pcm_decode.rs"
harness = false
required-features = ["audio"]
[[bench]]
name = "simd_quantize"
path = "benches/simd_quantize.rs"
harness = false
required-features = ["audio"]
[[bench]]
name = "simd_rgb_widen"
path = "benches/simd_rgb_widen.rs"
harness = false
required-features = ["vlm"]
[dependencies.cpal]
version = "0.17"
optional = true
[dependencies.ctor]
version = "1"
[dependencies.derive_more]
version = "2"
features = [
"display",
"is_variant",
"unwrap",
"try_unwrap",
]
default-features = false
[dependencies.glob]
version = "0.3"
optional = true
[dependencies.half]
version = "2"
[dependencies.image]
version = "0.25"
features = [
"png",
"jpeg",
]
optional = true
default-features = false
[dependencies.jiff]
version = "0.2"
optional = true
[dependencies.libc]
version = "0.2"
[dependencies.llguidance]
version = "1.7"
features = [
"lark",
"referencing",
]
optional = true
default-features = false
[dependencies.memspan]
version = "0.1"
optional = true
[dependencies.minijinja]
version = "2"
features = [
"loader",
"json",
"loop_controls",
"builtins",
"preserve_order",
]
optional = true
[dependencies.minijinja-contrib]
version = "2"
features = ["pycompat"]
optional = true
[dependencies.mlxrs-sys]
version = "0.1"
[dependencies.regex]
version = "1"
features = [
"std",
"perf",
]
optional = true
default-features = false
[dependencies.serde]
version = "1"
features = ["derive"]
optional = true
[dependencies.serde_json]
version = "1"
features = ["preserve_order"]
optional = true
[dependencies.smallvec]
version = "1"
[dependencies.smol_str]
version = "0.3"
[dependencies.static_assertions]
version = "1"
[dependencies.symphonia]
version = "0.6"
features = [
"wav",
"pcm",
"mp3",
"flac",
"ogg",
"vorbis",
]
optional = true
default-features = false
[dependencies.thiserror]
version = "2"
[dependencies.tokenizers]
version = "0.23"
features = ["onig"]
optional = true
default-features = false
[dependencies.toktrie_hf_tokenizers]
version = "1.7"
optional = true
[dependencies.unicode-normalization]
version = "0.1"
optional = true
[dev-dependencies.approx]
version = "0.5"
[dev-dependencies.criterion]
version = "0.8"
[dev-dependencies.libc]
version = "0.2"
[dev-dependencies.trybuild]
version = "1"
[target."cfg(unix)".dependencies.xattr]
version = "1"
optional = true
[lints.clippy]
large_types_passed_by_value = "deny"
map_clone = "deny"
needless_collect = "deny"
needless_pass_by_value = "deny"
redundant_allocation = "deny"
redundant_clone = "deny"
result_large_err = "allow"
undocumented_unsafe_blocks = "deny"
unnecessary_to_owned = "deny"
unnecessary_wraps = "deny"
[lints.rust]
rust_2018_idioms = "warn"
single_use_lifetimes = "warn"
[lints.rust.unexpected_cfgs]
level = "warn"
priority = 0
check-cfg = [
"cfg(all_tests)",
"cfg(tarpaulin)",
"cfg(mlxrs_force_scalar)",
]