DSP Libraries
HiFi 5 Signal Processing Library
Overview
The HiFi 5 NatureDSP (NDSP) library, also known as the NatureDSP signal processing library, provides a large number of highly optimized DSP functions for HiFi 5 DSP.
This source code repository contains ANSI-C compatible C functions for general signal processing (filtering, correlation, convolution), mathematical operations, and vector operations, specifically optimized for high-density signal processing. The library supports both fixed-point and single-precision floating-point data types.
Pre-compiled HiFi 5 NDSP libraries are provided in {DSP_SDK}/lib/lib_hifi5. For other requirements, you can also compile them yourself by downloading the official repository code.
More Information
Official Documentation: Located in the NDSP_HiFi5/library/doc directory after extracting the GitHub repository archive
Function Support
The NDSP library contains implementations of the following functions:
FIR filters and correlation functions
IIR filters
Mathematical operations
Complex mathematical operations
Vector operations
Matrix operations
Matrix decomposition and inversion functions
Fitting/interpolation
Fast Fourier Transform
Mel-Frequency Cepstral Coefficients (MFCC) functions
Image processing
For more details, please refer to the official Cadence documentation.
HiFi 5 Neural Network Library
Introduction
The HiFi 5 Neural Network (NN) library is an implementation of neural network layers and low-level operations optimized for HiFi processors. This library focuses on the speech and audio domain and is designed for related neural networks.
The low-level NN kernels in the library are optimized for HiFi and form the foundation of NN layers, providing generic and concise interfaces. NN layers are implemented based on these low-level kernels and can accept input data with up to four-dimensional shapes, generating output with corresponding shapes.
Weights (or coefficients) and biases required for layer operations are stored externally. The shapes of inputs, outputs, weights, and biases strictly follow the design specifications of each layer.
Precompiled HiFi 5 neural network libraries are provided in {DSP_SDK}/lib/xa_nnlib. For other requirements, you can also download the official repository code to compile manually.
Operation Support
Low-level Kernels
Matrix-vector multiplication kernel
Convolution kernel
Activation function kernel
Pooling kernel
Basic operation kernel
Fully connected kernel
Normalization kernel
Reshuffling kernel
These kernels support fixed-point 8-bit, 16-bit, single-precision floating-point (float32/f32), and half-precision floating-point (float16/f16) data types for weights/coefficients, biases, inputs, and outputs.
Additionally, some kernels also support 8-bit and 16-bit quantized data types defined in TensorFlow (TF) and TensorFlowLite-Micro (TFLM). These data types use 8-bit/16-bit quantized values (asym8u - asymmetric 8-bit unsigned, asym8s - asymmetric 8-bit signed, sym8s - symmetric 8-bit signed) for weights/coefficients, inputs, and outputs. Biases are 32-bit quantized values.
Layers
GRU layer (8x16, 16x16 precision)
LSTM layer (8x16, 16x16 precision)
CNN layer (8x8, 8x16, 16x16, and float32xfloat32 precision)
TensorFlow Lite Micro Operators
The HiFi 5 NN library low-level kernels can be used to implement some TensorFlow Lite Micro operators. For applicable operators, the HiFi 5 NN library supports both rounding modes available in TensorFlow Lite Micro.
For more details, please refer to the official Cadence documentation.
Acceleration Performance
Using the HiFi 5 neural network library can significantly improve the inference speed of neural networks.
Take {DSP_SDK}/example/tflite_micro/tflm_mnist as an example:
Example |
Time without nnlib (milliseconds) |
Time with nnlib (milliseconds) |
Speedup |
|---|---|---|---|
tflm_mnist |
2378 |
72 |
33 |