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//! - [`dsp_bridge`] (feature `embedded-dsp`): Quantize `embedded-dsp` FFT
24//!   output into this crate's tensors.
25
26#![no_std]
27#![deny(missing_docs)]
28
29pub mod activations;
30pub mod basic_math;
31pub mod concat;
32pub mod convolution;
33#[cfg(feature = "embedded-dsp")]
34pub mod dsp_bridge;
35pub mod float_ops;
36pub mod fully_connected;
37pub mod pad;
38pub mod pooling;
39pub mod recurrent;
40pub mod reshape;
41pub mod simd;
42pub mod softmax;
43pub mod subbyte;
44pub mod support;
45pub mod transpose;
46pub mod types;
47
48pub use support::{
49    clamp, divide_by_power_of_two, doubling_high_mult_no_sat, pack_q15x2_32x1, pack_s8x4_32x1,
50    requantize, requantize_s64,
51};
52pub use types::{
53    Activation, Context, ConvParams, Dims, DwConvParams, Error, FcParams, PerChannelQuantParams,
54    PerTensorQuantParams, PoolParams, QuantParams, Result, SoftmaxParams, Tile,
55};
56
57pub use convolution::{convolve_1_x_n_s8, transpose_conv_s8};
58#[cfg(feature = "embedded-dsp")]
59pub use dsp_bridge::{quantize_power_spectrum_s16, quantize_power_spectrum_s8};
60pub use float_ops::{f16_to_f32, f32_to_f16};
61pub use fully_connected::{batch_matmul_s16, batch_matmul_s8};
62pub use recurrent::{lstm_step_s16, lstm_step_s8_s16, svdf_s8, svdf_state_s16_s8, LstmGateParams};
63pub use simd::{vec_dot_s16, vec_dot_s8};
64pub use subbyte::{convolve_s4, fully_connected_s4, pack_s4_pair, unpack_s4_pair};