Skip to main content

embedded_nn/
lib.rs

1//! # embedded-nn
2//!
3//! `embedded-nn` is a pure Rust, `#![no_std]` neural network inference library for microcontrollers and embedded targets,
4//! inspired by ARM's CMSIS-NN and TensorFlow Lite Micro.
5//!
6//! ## Modules
7//! - [`types`]: Dimensional shapes, parameter structures, error types.
8//! - [`support`]: Fixed-point quantization math, rounding division, bit operations.
9//! - [`activations`]: ReLU, ReLU6, LeakyReLU, Sigmoid, Tanh.
10//! - [`basic_math`]: Elementwise addition, subtraction, and multiplication.
11//! - [`convolution`]: 2D Convolution, 1x1 Convolution, Depthwise Convolution, Transposed Conv, 1D Temporal Conv.
12//! - [`fully_connected`]: Fully Connected (Linear / Dense) layers and Batch Matrix Multiplication (`BatchMatMul`).
13//! - [`pooling`]: Max Pooling, Average Pooling.
14//! - [`softmax`]: Softmax activation.
15//! - [`concat`]: Depthwise concatenation.
16//! - [`pad`]: Tensor padding.
17//! - [`transpose`]: Matrix and spatial transposition.
18//! - [`reshape`]: Reshaping operations.
19//! - [`simd`]: Target SIMD vectorization abstractions, ARM DSP SMLAD assembly, and dot-product acceleration.
20//! - [`subbyte`]: Sub-byte 4-bit (`s4`) quantization layers and packing helpers.
21//! - [`recurrent`]: Recurrent neural network layers (LSTM cell, SVDF filter with 8-bit & 16-bit state).
22//! - [`float_ops`]: Floating-point (`f32` & IEEE-754 `f16`) fallback layers.
23
24#![no_std]
25#![deny(missing_docs)]
26
27pub mod activations;
28pub mod basic_math;
29pub mod concat;
30pub mod convolution;
31pub mod float_ops;
32pub mod fully_connected;
33pub mod pad;
34pub mod pooling;
35pub mod recurrent;
36pub mod reshape;
37pub mod simd;
38pub mod softmax;
39pub mod subbyte;
40pub mod support;
41pub mod transpose;
42pub mod types;
43
44pub use support::{
45    clamp, divide_by_power_of_two, doubling_high_mult_no_sat, pack_q15x2_32x1, pack_s8x4_32x1,
46    requantize, requantize_s64,
47};
48pub use types::{
49    Activation, Context, ConvParams, Dims, DwConvParams, Error, FcParams, PerChannelQuantParams,
50    PerTensorQuantParams, PoolParams, QuantParams, Result, SoftmaxParams, Tile,
51};
52
53pub use convolution::{convolve_1_x_n_s8, transpose_conv_s8};
54pub use float_ops::{f16_to_f32, f32_to_f16};
55pub use fully_connected::{batch_matmul_s16, batch_matmul_s8};
56pub use recurrent::{lstm_step_s16, lstm_step_s8_s16, svdf_s8, svdf_state_s16_s8, LstmGateParams};
57pub use simd::{vec_dot_s16, vec_dot_s8};
58pub use subbyte::{convolve_s4, fully_connected_s4, pack_s4_pair, unpack_s4_pair};