Quantization and Dequantization Introduction
In order to help you better understand the quantize and dequantize pre-processing provided by the DSP sample package, this article analyzes the CPU and DSP reference implementations based on the algorithm principles, and performs consistency checks and performance evaluations on the CPU and DSP reference implementations.
Principle Introduction
Quantization and Dequantization
For the introduction, formulas and reference implementation of quantization and dequantization, please refer to the introduction of model quantization in the Key Concepts section.
CPU Reference Implementation
Quantification
Dequantization
DSP Optimization Acceleration
DSP Acceleration Ideas
Vectorized
Quantize/dequantize both calculate data continuously, which is very suitable for SIMD vector optimization.
Block strategy
-
J6 DSP has two 256kB TCMs, and the actual available space is about 210KB. Each tile is as large as possible without exceeding the total available space. Quantize mainly considers input and output, and the ratio is 4:1. Dequantize also mainly considers input and output, and the ratio is 1:4;
-
At the same time, because quantize is a linear calculation, and the output is smaller than the output data size, you can consider using inplace (using the same tile for input and output to further increase the available tile).
DSP Optimization Implementation
- quantize SIMD computing.
- dequantize SIMD Computing.
- For the framework part, please refer to the introduction of ping pong IDMA implementation in the DSP Operator section.
Consistency Check
Compare the calculated results with the CPU reference implementation, and pass the verification if they are consistent
