Introduction
Edge AI on TI microcontrollers (MCUs) involves running machine learning algorithms directly on Texas Instruments' processors. TI's C2000 MCUs enable AI processing at the edge without cloud connectivity. These MCUs incorporate specialized hardware accelerators (TINPU) and optimized software libraries for efficient neural network execution despite limited resources. Applications include predictive maintenance, voice recognition, and sensor analytics in IoT devices. TI's development ecosystem supports machine learning frameworks like PyTorch and provides tools to optimize models for their constrained environments.
Features Supported
Implements the embedded feature-extraction pipeline used before inference. The pipeline supports preprocessing
- Mean removal
- Windowing (Hann)
- FFT
- FFT normalization
- DC removal
- Frequency binning
- Log scaling
- Frame concatenation (sliding window)
- Optional batch normalization / quantization support for NPU Quantized models.
Features Not Supported
- Batch Normalization / quantization support for CPU Quantized models
- Integer implementations of features
- FFT of frame sizes other than power of 2
- Hanning window other than {32, 64, 128, 256, 512, 1024, 2048}
- Pre Calculated twiddle factor coefficients
Quick Usage
// Allocate and initialize
feature_extraction fe = {0};
fe.input_buffer = input_ptr; // float samples: size = FE_VARIABLES * FE_FRAME_SIZE
fe.output_buffer = output_ptr; // pre-allocated output area
fe.history_buffer = history_ptr; // optional
FE_allocFeatureExtract(&fe); // sets fe.size_required_by_library
fe.scratch_buffer = malloc(fe.size_required_by_library);
FE_initFeatureExtract(&fe);
// Process frames (per call will iterate channels as configured)
FE_runFeatureExtract(&fe);
// compare / validate
int mismatches = FE_compareModelInput(expected, actual);
API Usage
Public API (high level)
Data Structures
- feature_extraction: Context structure that holds pointers to input, output, history and scratch buffers plus a few runtime flags and a size field.
- input_buffer: pointer to samples to process.
- output_buffer: pointer where extracted features will be written.
- history_buffer: optional pointer used for initialization/history handling.
- scratch_buffer: workspace used during processing (size requested by FE_allocFeatureExtract).
- test_feature_extraction: boolean to toggle test-mode output handling.
- size_required_by_library: returned by FE_allocFeatureExtract to indicate scratch size requirements.
Types & Configuration
- model_input_t: Input sample type — int8_t when SKIP_NORMALIZE is defined, otherwise float.
- model_output_t: Output sample type — int8_t when OUTPUT_INT is defined, otherwise float.
- Important compile-time macros:
- Functions: FE_RAW, FE_WIN, FE_FFT, FE_NORMALIZE, FE_DC_REM, FE_BIN, FE_LOG, FE_CONCAT, SKIP_NORMALIZE, OUTPUT_INT.
- Parameters for functions: FE_FRAME_SIZE, FE_FFT_STAGES, FE_FEATURE_SIZE_PER_FRAME, FE_MIN_FFT_BIN, FE_FFT_BIN_SIZE, FE_BIN_NORMALIZE, FE_STACKING_CHANNELS, FE_STACKING_FRAME_WIDTH, FE_VARIABLES, FE_NUM_FRAME_CONCAT, FE_NN_OUT_SIZE
Pipeline overview (what FE_runFeatureExtract does, depending on build flags)
- Input copy: copies a frame from
fe->input_buffer into fe->scratch_buffer.
- FE_RAW (optional): mean removal (subtract frame mean) to center the signal.
- FE_WIN (optional): compute and apply a Hann window (symmetric) to the frame.
- FE_FFT (optional): run complex FFT, producing an interleaved complex spectrum then magnitudes.
- FE_NORMALIZE (optional): divide FFT magnitudes by the FFT size.
- FE_DC_REM (optional): drop/shift DC bin from the spectrum.
- FE_BIN (optional): reduce spectrum length to
FE_FEATURE_SIZE_PER_FRAME by summing or averaging frequency bins.
- FE_LOG (optional): apply log scaling to the binned/magnitude values.
- FE_CONCAT (optional): shift previous frames and concatenate features to form a temporal context (sliding window).
- Batch normalization / quantize: either
FE_batchNormalization_npu (when SKIP_NORMALIZE is enabled and quantized model path is used) or copy the float outputs directly into output_buffer.
Edge AI Examples