Axon DSP intrinsics
Axon intrinsics are functions that use the Axon NPU to perform DSP-like and DMA vector operations using fixed-point arithmetic. They are declared in the Axon DSP intrinsics API and run directly on the NPU without compiling a TensorFlow Lite model.
Fixed-point arithmetic
All Axon intrinsics use fixed-point arithmetic.
Results saturate at the maximum and minimum limits of the output size.
The rounding_bits parameter sets how many bits to round off each result.
A variety of input and output bit widths are supported:
Inputs can be 8, 16, 24, and in rare cases 32 bits.
Outputs can be 8, 16, 24, and 32 bits.
24-bit input and output values are sign-extended to 32 bits internally.
Each intrinsic targets a specific combination of input and output bit widths. The intrinsic function name incorporates its input and output bit widths.
Not all permutations of bit widths are implemented for every operation.
Synchronous execution
Axon intrinsics execute synchronously. Each intrinsic first acquires a hardware-access mutex. This step is short-circuited if the calling thread already owns the mutex.
You can select the blocking mechanism, event or polling, through the block_mode parameter.
Polling is recommended in most cases unless there is another thread that occupies the CPU while the intrinsic executes.
Intrinsic execution times are often too short for the power saved during CPU sleep to exceed the overhead of entering and exiting sleep.
Upon completion, the hardware-access mutex is released if keep_reservation is false.
Acquiring the mutex adds overhead.
Set keep_reservation to true to retain the mutex across a sequence of intrinsics, then set it to false on the final call in the sequence.
Performance benefits compared to the CPU
Certain Axon intrinsics outperform the CPU. Exponential, natural log, FFT, square root, and FIR filters almost always perform significantly better than Cortex-M33 execution.
Other intrinsics offer a smaller improvement that becomes noticeable only with longer vectors.
Examples include a*x + b*y, accumulation, and MAR (dot product) operations.
Developing with Axon intrinsics
Develop algorithms with the Axon simulator before testing and deploying on target hardware.
Applications under tests/axon can serve as templates for builds targeting both the simulator and Zephyr.
Test: DSP intrinsics invokes each supported intrinsic at least once. See Axon driver DSP intrinsics for build and run instructions.
Intrinsic calling conventions
All intrinsics use fixed-point arithmetic with configurable rounding and saturation to the output bit-width maximum and minimum values.
rounding_bitsspecifies the rounding amount. It is functionally equivalent to a right shift followed by rounding.The intrinsic name incorporates input and output bit widths (8, 16, 24, and 32). A single number implies the same input and output bit width. Two numbers indicate input and output bit widths respectively. Three numbers indicate the first input, second input, and output bit widths.
24-bit input must be sign-extended to 32 bits. 24-bit output is sign-extended to 32 bits.
Some intrinsics can generate 32-bit output, but very few consume 32-bit input. 32-bit output typically must be consumed by the CPU directly.
Intrinsics reserve hardware access through a driver-managed mutex. Set
keep_reservationtotrueto avoid releasing and re-acquiring hardware access between consecutive intrinsic calls. Set it tofalseon the last intrinsic in a sequence.Some intrinsics are compound operations that execute multiple hardware commands. Rounding may be applied at one or more stages. Refer to the Axon DSP intrinsics API documentation for details.
Intrinsic listing
The following intrinsics are currently supported. The tables below summarize the available functions. Click a function name to open its API reference.
FFT
Function |
Description |
|---|---|
24-bit complex FFT on unpacked 32-bit samples. |
|
24-bit complex FFT followed by power spectrum computation. |
FIR filters
Function |
Description |
|---|---|
FIR filter with 24-bit input, 24-bit coefficients, and 24-bit output. |
|
FIR filter with 24-bit input, 16-bit coefficients, and 24-bit output. |
|
2D FIR filter with decimation. |
|
2D FIR filter with 24-bit output and decimation. |
|
1D FIR filter with decimation. |
|
1D FIR filter with decimation factor 1 for 1024-input, 256-tap workloads. |
|
1D FIR filter with decimation factor 4 for 1024-input, 256-tap workloads. |
|
Complex 2D FIR filter with decimation. |
|
Complex 2D FIR filter with 32-bit output and decimation. |
Vector operations
Function |
Description |
|---|---|
Element-wise multiply of two 24-bit vectors. |
|
Element-wise multiply of two 16-bit vectors with 32-bit output. |
|
Element-wise multiply with configurable output stride and rounding. |
|
Element-wise addition of two 24-bit vectors. |
|
Element-wise subtraction of two 24-bit vectors. |
|
Multiply a vector by a scalar value. |
|
Scalar multiply with input stride of 2. |
|
Multiply a vector by a scalar, then subtract another vector. |
|
Affine combination |
|
Affine transform |
|
2D affine transform on 8-bit input with 16-bit output. |
|
2D affine transform on 16-bit data. |
|
Scale a vector by a scalar value. |
|
Element-wise absolute value. |
Math functions
Function |
Description |
|---|---|
Square root on 24-bit fixed-point values. |
|
Natural logarithm with 11.12 fixed-point format. |
|
Exponential function with 11.12 fixed-point format. |
Matrix and accumulation
Function |
Description |
|---|---|
Matrix multiply with 16-bit and 24-bit operands and 32-bit output. |
|
Matrix multiply with 24-bit output. |
|
Matrix multiply with 16-bit operands and 32-bit output. |
|
Matrix multiply with 24-bit operands and 32-bit output. |
|
Matrix multiply with 24-bit operands and output. |
|
Matrix multiply with 16-bit operands and 24-bit output. |
|
Matrix multiply with transposed right-hand operand. |
|
Matrix multiply with 16-bit input and transposed right-hand operand. |
|
Matrix multiply with transposed right-hand operand and 24-bit output. |
|
Matrix multiply with 16-bit input, transposed right-hand operand, and 24-bit output. |
|
Accumulate vector elements into a scalar. |
|
Accumulate 16-bit vector elements into a 32-bit scalar. |
|
Accumulate 24-bit vector elements into a 32-bit scalar. |
|
Accumulate 24-bit vector elements into a 24-bit scalar. |
|
L2 norm of a 16-bit vector with 24-bit output. |
|
L2 norm of a 16-bit vector with 32-bit output. |
|
L2 norm of a 24-bit vector. |
|
L2 norm of a 24-bit vector with 32-bit output. |
Memory and utility
Function |
Description |
|---|---|
Fill a buffer with a 32-bit value using configurable output stride. |
|
Saturate 32-bit values to 24-bit range. |
|
Saturate 32-bit values to 8-bit range. |
2D operations
Function |
Description |
|---|---|
2D memory copy with configurable width, height, and strides. |