oxedyne/fe2o3/fe2o3_infer/src/lib.rs
1.8 KiB, 22 runs
created by r1870400018:19733, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | //! Convolutional inference on the CPU, with no dependency beyond `fe2o3_core`. |
| 2 | //! |
| 3 | //! The crate carries three layers: |
| 4 | //! |
| 5 | //! - [`kern`] -- safe `f32` kernels behind one runtime dispatch, so that a |
| 6 | //! binary built for a stock target still reaches the vector unit of the |
| 7 | //! machine it lands on. |
| 8 | //! - [`onnx`] and [`graph`] -- a loader for the subset of ONNX that a small |
| 9 | //! convolutional network uses, and a runner over the operators it yields. |
| 10 | //! - [`face`] -- the two things built on top: a face detector that returns |
| 11 | //! boxes with five landmarks, and an embedder that turns an aligned crop |
| 12 | //! into a vector two faces can be compared with. |
| 13 | //! |
| 14 | //! # Owning nothing |
| 15 | //! |
| 16 | //! Nothing here reads a file, opens a socket, or starts a thread. Weights |
| 17 | //! arrive as `&[u8]` and images arrive as pixels; where they came from and how |
| 18 | //! the work is spread across cores are the caller's business. That keeps the |
| 19 | //! crate usable from a scanner, a server or a test with equal ease. |
| 20 | //! |
| 21 | //! # Layout |
| 22 | //! |
| 23 | //! Activations are held channels-last, `[N, H, W, C]`. In that layout a one by |
| 24 | //! one convolution *is* a matrix product with no gather in front of it, a |
| 25 | //! depthwise convolution vectorises over channels, and a per-channel scale or |
| 26 | //! slope is a unit-stride pass. The loader permutes the weights once so that |
| 27 | //! the runner never has to transpose an activation. |
| 28 | //! |
| 29 | //! # Safety |
| 30 | //! |
| 31 | //! The crate denies `unsafe` code with one documented exception, in |
| 32 | //! [`kern::run`], where calling a `#[target_feature]` function from an |
| 33 | //! unfeatured context requires the token even though the body is safe. There |
| 34 | //! are no raw pointers, no intrinsics, and no hand-written assembly anywhere. |
| 35 | #![deny(unsafe_code)] |
| 36 | |
| 37 | #[macro_use] |
| 38 | pub mod macros; |
| 39 | |
| 40 | pub mod face; |
| 41 | pub mod graph; |
| 42 | pub mod kern; |
| 43 | pub mod object; |
| 44 | pub mod onnx; |
| 45 | pub mod prelude; |
| 46 | pub mod tensor; |