4. Floating-point Model Convert to Fixed-point Model Guide¶
D-Robotics provides you with two methods to convert floating-point model to fixed-point model, which are PTQ model quantization scheme and QAT model quantization scheme. This section brings you the description of Post-training Quantization (PTQ) and Quantized Awareness Training (QAT) .
- 4.1. Post-training Quantization (PTQ)
- 4.1.1. PTQ Principle and Steps
- 4.1.1.1. PTQ Conversion Process and Steps
- 4.1.1.2. Operator Constraints
- 4.1.1.3. Floating-point Model Preparation
- 4.1.1.4. Check the Model
- 4.1.1.5. Prepare Calibration Data
- 4.1.1.6. Model Quantization and Compilation
- 4.1.1.7. Model Performance Analysis and Optimization
- 4.1.1.8. Model Accuracy Analysis and Optimization
- 4.1.1.9. Other Dev Tools (Optional)
- 4.1.1.10. Post-training Quantization (PTQ) FAQ
- 4.1.1.10.1. How to understand the two forms of BPU acceleration and CPU computation mentioned in the operator constraint?
- 4.1.1.10.2. How does model segmentation affect the performance?
- 4.1.1.10.3. Why some OPs supported by BPU at the tail part of the model running on CPU?
- 4.1.1.10.4. Does it support asymmetric quantization?
- 4.1.1.10.5. How to understand D-Robotics’ default calibration method?
- 4.1.1.10.6. How to understand D-Robotics’ mix calibration method?
- 4.1.1.10.7. How to understand the compiler optimization level parameters in yaml files?
- 4.1.1.10.8. Why does the input size derived from the nv12 model hb_perf not match the prediction library?
- 4.1.1.10.9. Is the data layout of the inputs to the quantized model and the on-board bin model necessarily the same?
- 4.1.1.10.10. How to compile to get a multi-batch model?
- 4.1.1.10.11. Is it normal for the order of model inputs to change during the conversion of a multi-input model?
- 4.1.1.11. Custom OP Development
- 4.1.2. PTQ Tools Guide
- 4.1.2.1. Model Conversion Process
- 4.1.2.1.1. Model Checking (hb_mapper checker)
- 4.1.2.1.2. Calibration Image Preparation
- 4.1.2.1.3. Model Conversion (
hb_mapper makertbin) - 4.1.2.1.4. Single Image Inference
- 4.1.2.1.5. Model Accuracy Evaluations
- 4.1.2.1.6. Model Performance Evaluations
- 4.1.2.1.7. [Reference] Supported Calibration Methods
- 4.1.2.1.8. [Reference] OP List
- 4.1.2.2. The hb_mapper Tools
- 4.1.2.3. The hb_perf Tool
- 4.1.2.4. The vec_diff Tool
- 4.1.2.5. The hb_model_info Tool
- 4.1.2.6. The hb_pack Tool
- 4.1.2.7. The hb_verifier Tool
- 4.1.2.8. The hb_model_modifier Tool
- 4.1.2.9. The hb_custom_op Tool
- 4.1.2.10. The hb_eval_preprocess Tool
- 4.1.2.11. The HB_ONNXRuntime Inference Library
- 4.1.2.12. Accuracy Debug Tool
- 4.1.2.1. Model Conversion Process
- 4.1.3. PTQ Model Conversion Samples Guide
- 4.1.3.1. Release Introduction
- 4.1.3.2. Common Algorithm Model Samples
- 4.1.3.2.1. Where to Find
- 4.1.3.2.2. Prepare Dataset
- 4.1.3.2.3. Prepare Models
- 4.1.3.2.3.1. Fcos_efficientnetb0
- 4.1.3.2.3.2. Fcos_efficientnetb1
- 4.1.3.2.3.3. Fcos_efficientnetb2
- 4.1.3.2.3.4. MobileNetv1/v2
- 4.1.3.2.3.5. GoogleNet
- 4.1.3.2.3.6. ResNet18
- 4.1.3.2.3.7. Mobilenet_onnx
- 4.1.3.2.3.8. EfficientNet_Lite0/1/2/3/4
- 4.1.3.2.3.9. YOLOv2_Darknet19
- 4.1.3.2.3.10. YOLOv3_Darknet53
- 4.1.3.2.3.11. YOLOv5s
- 4.1.3.2.3.12. SSD_MobileNetv1
- 4.1.3.2.3.13. EfficientDetd0
- 4.1.3.2.3.14. CenterNet_Resnet50
- 4.1.3.2.3.15. Fcos_efficientnetb0
- 4.1.3.2.3.16. UNet_mobilenet
- 4.1.3.2.3.17. DeeplabV3plus_efficientnetb0
- 4.1.3.2.3.18. Fastscnn_efficientnetb0
- 4.1.3.2.4. A Demonstration of the Algorithm Model Samples
- 4.1.3.2.5. FAQ
- 4.1.3.2.5.1. How to match the inference results of the ONNX original floating-point model and the
hb_mapper makertbintool generated *_original_float_model.onnx model? - 4.1.3.2.5.2. Why is the reproduced accuracy slightly different from the indicators in the documentation?
- 4.1.3.2.5.3. Why is the fixed-point model accuracy not aligned with the on-board accuracy of the bin file in the ai_benchmark example?
- 4.1.3.2.5.1. How to match the inference results of the ONNX original floating-point model and the
- 4.1.3.3. Other Algorithm Model Samples
- 4.1.3.3.1. How to Use
- 4.1.3.3.2. Miscellaneous Samples
- 4.1.3.3.3. User Custom OP Sample
- 4.1.4. Appendix
- 4.1.4.1. norm_type Configuration Description
- 4.1.4.2. Image Processing Transformer Description
- 4.1.4.2.1. AddTransformer
- 4.1.4.2.2. MeanTransformer
- 4.1.4.2.3. ScaleTransformer
- 4.1.4.2.4. NormalizeTransformer
- 4.1.4.2.5. TransposeTransformer
- 4.1.4.2.6. HWC2CHWTransformer
- 4.1.4.2.7. CHW2HWCTransformer
- 4.1.4.2.8. CenterCropTransformer
- 4.1.4.2.9. PILCenterCropTransformer
- 4.1.4.2.10. LongSideCropTransformer
- 4.1.4.2.11. PadResizeTransformer
- 4.1.4.2.12. ResizeTransformer
- 4.1.4.2.13. PILResizeTransformer
- 4.1.4.2.14. ShortLongResizeTransformer
- 4.1.4.2.15. PadTransformer
- 4.1.4.2.16. ShortSideResizeTransformer
- 4.1.4.2.17. PaddedCenterCropTransformer
- 4.1.4.2.18. BGR2RGBTransformer
- 4.1.4.2.19. RGB2BGRTransformer
- 4.1.4.2.20. RGB2GRAYTransformer
- 4.1.4.2.21. BGR2GRAYTransformer
- 4.1.4.2.22. RGB2GRAY_128Transformer
- 4.1.4.2.23. RGB2YUV444Transformer
- 4.1.4.2.24. BGR2YUV444Transformer
- 4.1.4.2.25. BGR2YUV444_128Transformer
- 4.1.4.2.26. RGB2YUV444_128Transformer
- 4.1.4.2.27. BGR2YUVBT601VIDEOTransformer
- 4.1.4.2.28. RGB2YUVBT601VIDEOTransformer
- 4.1.4.2.29. YUVTransformer
- 4.1.4.2.30. ReduceChannelTransformer
- 4.1.4.2.31. BGR2NV12Transformer
- 4.1.4.2.32. RGB2NV12Transformer
- 4.1.4.2.33. NV12ToYUV444Transformer
- 4.1.4.2.34. WarpAffineTransformer
- 4.1.4.2.35. F32ToS8Transformer
- 4.1.4.2.36. F32ToU8Transformer
- 4.1.4.3. Common Failure Resolutions
- 4.1.1. PTQ Principle and Steps
- 4.2. Quantized Awareness Training (QAT)
- 4.2.1. Environmental Dependence
- 4.2.2. Quick Start
- 4.2.2.1. Building A Floating Point Model
- 4.2.2.2. Pre-train A Floating Point Model
- 4.2.2.3. Set BPU Architectures
- 4.2.2.4. Operator Fusion
- 4.2.2.5. Convert A Floating Point Model To A Quantitative Model
- 4.2.2.6. Quantization Aware Training (QAT)
- 4.2.2.7. Converting a Quantized Model to a Fixed-point Model
- 4.2.2.8. Check and Compile a Fixed-point Prediction Model
- 4.2.3. TUTORIAL
- 4.2.3.1. Floating Point Model Preparation
- 4.2.3.2. Operator Fusion
- 4.2.3.3. Set Up Different BPU Architectures
- 4.2.3.4. Heterogeneous Model QAT
- 4.2.3.5. FX Based Quantization
- 4.2.3.6. Building Quantization-friendly Floating-point Models
- 4.2.3.7. QAT Experience Summary
- 4.2.3.8. Model Precision Debug Tool
- 4.2.3.8.1. Similarity
- 4.2.3.8.2. Visualization
- 4.2.3.8.3. Statistics
- 4.2.3.8.4. Step Quantization
- 4.2.3.8.5. Shared OP Check
- 4.2.3.8.6. Fuse Check
- 4.2.3.8.7. Single-operator Conversion Precision Debugging
- 4.2.3.8.8. Quantitative Configuration Check
- 4.2.3.8.9. Model Weight Comparison
- 4.2.3.8.10. Deploy Device Check of Hybrid Models
- 4.2.3.8.11. Integrated Interface
- 4.2.3.8.12. GPU Memory Profiler
- 4.2.3.9. Ideas of Quantization Precision Debug
- 4.2.4. API REFERRENCE
- 4.2.5. NOTE
- 4.2.6. Calibration