[package]
authors = ["Dilshod Tadjibaev (@antimora)"]
categories = ["science", "mathematics", "no-std"]
description = "A fast, portable CPU backend for the Burn framework"
documentation = "https://docs.rs/burn-flex"
edition.workspace = true
keywords = ["deep-learning", "machine-learning", "tensor", "simd"]
license.workspace = true
name = "burn-flex"
readme.workspace = true
repository = "https://github.com/tracel-ai/burn/tree/main/crates/burn-flex"
version.workspace = true

[lints]
workspace = true

[features]
default = ["std", "simd", "rayon"]
doc = ["default"]
std = [
    "gemm/std",
    "burn-backend/std",
    "burn-std/std",
    "burn-ir/std",
    "half/std",
    "num-traits/std",
]
simd = ["dep:macerator", "dep:aligned-vec", "gemm/wasm-simd128-enable"]
rayon = ["dep:rayon", "gemm/rayon"]
# Opt-in gemm codegen paths. Not enabled by default.
# AVX-512 kernels for x86_64 (Sapphire Rapids, Zen 4/5, etc.).
x86-v4 = ["gemm/x86-v4"]
# Apple AMX matrix coprocessor (M-series). Experimental upstream; requires std.
apple-amx = ["std", "gemm/experimental-apple-amx"]
tracing = ["burn-std/tracing", "burn-backend/tracing", "burn-ir/tracing"]
critical-section = [
    "dep:once_cell",
    "once_cell/critical-section",
    "dep:portable-atomic",
    "portable-atomic/critical-section",
    "dep:portable-atomic-util",
]

[dependencies]

# ** Please make sure all dependencies support no_std when std is disabled **

burn-backend = { workspace = true }
burn-ir = { workspace = true }
burn-std = { workspace = true }

bytemuck = { workspace = true }
half = { workspace = true }
# libm for `erf` (f32/f64). num-traits does not expose erf, and Rust's
# f64/f32 have no builtin erf method even with `std`. libm is already
# in the dep graph transitively via num-traits, so listing it here
# doesn't add a new dependency.
libm = { workspace = true }
num-traits = { workspace = true }

# Matmul
gemm = { workspace = true, features = ["f16"] }

# SIMD
aligned-vec = { workspace = true, optional = true }
macerator = { workspace = true, optional = true }

# Parallel
rayon = { workspace = true, optional = true }

# no_std targets without atomic CAS (enabled via `critical-section` feature)
once_cell = { workspace = true, optional = true }
portable-atomic = { workspace = true, optional = true }
portable-atomic-util = { workspace = true, optional = true }

[dev-dependencies]
realfft = { workspace = true }

[package.metadata.docs.rs]
features = ["default"]
rustdoc-args = ["--cfg", "docsrs"]
