onnx_runtime_ep_cpu/lib.rs
1//! # `onnx-runtime-ep-cpu`
2//!
3//! The CPU execution provider for the ORT 2.0 runtime (see `docs/ORT2.md` §4.4
4//! and §54 Phase 1). It implements [`onnx_runtime_ep_api::ExecutionProvider`]
5//! and hosts pure-Rust reference kernels for the Phase-1 op set (`MatMul`,
6//! `Add`, `Relu`, `Reshape`, `Transpose`, `Gather`, `LayerNormalization`).
7//!
8//! ## Backends: correctness baseline + optional oneDNN
9//!
10//! The GEMM hot spot is served through [`backend::CpuBackend`] (`docs/ORT2.md`
11//! §25.2). The **default** backend is a pure-Rust blocked, register-tiled,
12//! rayon-parallelized f32 GEMM — the portable, offline correctness baseline that
13//! compiles anywhere with no C++/FFI. The non-default `onednn` cargo feature
14//! statically links oneDNN and routes the 2-D tile GEMM through `dnnl_sgemm`
15//! ([`kernels::onednn`]). Every backend lives behind the
16//! [`onnx_runtime_ep_api::Kernel`] trait, so neither the EP contract nor the
17//! session observes which one ran. See [`kernels::matmul`] for the hot spot.
18//!
19//! ## `unsafe`
20//!
21//! The default (Generic) path is `unsafe`-minimal: the only `unsafe` is the raw
22//! device-buffer access the ep-api contract forces (aligned host
23//! `alloc`/`dealloc`, `memcpy`, and strided element reads/writes), each isolated
24//! and `SAFETY`-documented, plus — only under the `onednn` feature — the
25//! `dnnl_sgemm` FFI call, confined to [`kernels::onednn`]. The blocked rayon GEMM
26//! itself contains no `unsafe`; all kernel arithmetic is safe Rust operating on
27//! dense `Vec<f32>` buffers produced by the two audited accessors in [`kernels`].
28
29pub mod backend;
30pub mod dtype;
31pub mod kernels;
32pub mod provider;
33pub mod strided;
34
35pub use backend::{CpuBackend, has_onednn};
36pub use provider::CpuExecutionProvider;
37
38pub use kernels::slice::{SliceAxisPlan, slice_axes_steps, slice_plan};