Skip to main content

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//! ## Correctness first, perf later
9//!
10//! The Phase-1 exit milestone is a **correctness** goal ("BERT on CPU matches
11//! upstream ORT"), so these kernels are straightforward, naive pure-Rust
12//! implementations — no C++/FFI, no oneDNN, no `cc` build dependency (oneDNN is
13//! not installed on the build host). Each kernel lives behind the
14//! [`onnx_runtime_ep_api::Kernel`] trait, leaving a clean seam for a Phase-1.5
15//! perf pass to drop in a blocked/SIMD GEMM (oneDNN via FFI, or a Rust BLAS such
16//! as `matrixmultiply`/`gemm`) without disturbing the EP contract or the
17//! session. See [`kernels::matmul`] for the hot spot.
18//!
19//! ## `unsafe`
20//!
21//! The crate is `unsafe`-minimal. The only `unsafe` is the raw device-buffer
22//! access the ep-api contract forces (aligned host `alloc`/`dealloc`, `memcpy`,
23//! and strided element reads/writes), each isolated and `SAFETY`-documented. All
24//! kernel arithmetic is safe Rust operating on dense `Vec<f32>` buffers produced
25//! by the two audited accessors in [`kernels`].
26
27pub mod kernels;
28pub mod provider;
29pub mod strided;
30
31pub use provider::CpuExecutionProvider;
32
33pub use kernels::slice::{slice_axes_steps, slice_plan, SliceAxisPlan};