fuel_cpu_backend/lib.rs
1// SPDX-License-Identifier: MIT OR Apache-2.0
2//! CPU backend computation kernels for fuel.
3//!
4//! This crate contains the core CPU computation helpers (MatMul, pooling,
5//! convolution, reductions, etc.) extracted from `fuel-core` so they can be
6//! reused and tested independently. It also re-exports the MKL and Accelerate
7//! FFI bindings when the corresponding features are enabled.
8
9#[cfg(feature = "accelerate")]
10pub mod accelerate;
11#[cfg(feature = "mkl")]
12pub mod mkl;
13
14// Link glue. `mkl` and `accelerate` declare `extern "C"` FFI against the vendor
15// libraries; nothing in this crate NAMES the `-src` crate that supplies the link
16// directives, and rustc drops an unreferenced crate from the link line, so
17// `extern crate` is what forces the native library in. It lives HERE, beside the
18// FFI it serves, so a binary that enables only `fuel-cpu-backend/mkl` links too
19// (GAP-348 (b); it used to sit in `fuel-core/src/lib.rs`).
20#[cfg(feature = "mkl")]
21extern crate intel_mkl_src;
22
23#[cfg(feature = "accelerate")]
24extern crate accelerate_src;
25
26pub mod conv2d;
27pub mod dyn_impl;
28pub mod host_storage;
29pub mod ops;
30pub mod probe;
31pub mod quantized;
32pub mod system_memory;
33pub mod utils;
34
35/// Phase 7.5 storage-unification target: byte-shaped CPU storage
36/// with `Arc<AlignedBytes>` backing, 64-byte alignment, and CoW
37/// mutation. Coexists with the legacy `CpuStorage` (HostBuffer-based)
38/// during op-kernel migration; legacy retires when the last kernel
39/// migrates.
40pub mod byte_storage;
41
42/// Typed byte-shaped kernels — Phase 7.5 B5. These operate on
43/// `CpuStorageBytes` directly via `bytemuck` typed views. The
44/// dispatch wrapper in `fuel_dispatch::dispatch::cpu_wrappers`
45/// extracts `CpuStorageBytes` from `BackendStorage::Cpu(...)` and
46/// calls these kernels.
47pub mod byte_kernels;
48
49/// Trait-chassis surface shared by elementwise + reduction CPU
50/// kernels. One shape/loop pass per kernel family; op-specific math
51/// lives in tiny trait impls. See [`chassis::reduction`].
52pub mod chassis;
53
54pub use byte_storage::{CPU_ALIGN_BYTES, CpuStorageBytes};
55pub use dyn_impl::CpuStorage;
56pub use ops::*;
57pub use quantized::CpuQStorage;
58pub use utils::*;