Performance Evaluation and Tuning
After completing the quantization and compilation of the model to obtain the hbm model deployed on the board side, we not only support the static performance of the BPU part of the model to be predicted on the developer side, but also provide executable tools on the board side that do not require any code development to help you quickly evaluate the dynamic performance of the model.
Static Performance Evaluation
-
If you are quantizing the model through the PTQ path and using the command line tool, the hb_compile tool will generate a static performance evaluation file (*.html & *.json) by default when it compiles the model, and at the same time, you can also evaluate the static performance of the model by calling the hbm_perf interface. The reference commands are as follows:
After successful execution, basic information such as model FPS will be printed within the terminal, and at the same time, a static performance evaluation file (model.html & model.json) will be generated for the model in the directory where the API interface is currently called. If you need to specify the path to the static performance evaluation file, you can refer to the following command:
-
If you are quantizing the model through the QAT path, you can just call the hbm_perf interface directly to perform a static performance evaluation of the model in the same way as described above.
Dynamic Performance Evaluation
Once the static performance of the model is as expected, we also support the further use of the hrt_model_exec tool to empirically measure the dynamic performance of the model due to the presence of dynamic properties in the Pyramid and Resizer input models.
The reference command is as follows:
For dynamic inputs, the requirement of stride is 32-aligned in the W direction, and the detailed calculation can be referred to the relevant contents of the introduction of UCP-Dynamic Inputs.
Assume that the input size of tensor valid_shape is (1,112,112,2), tensor_type=HB_DNN_TENSOR_TYPE_U8, stride= (-1,-1,2,1), then stride is calculated as follows:
For example, if the Pyramid input model with Y=(1,224,224,1) and UV=(1,112,112,2), the reference command would be as follows:
For the Resizer input model, the tool will specify the default ROI internally, and the default value is [0,0,127,127], so the default value can not meet the requirements of your model, you can refer to the following command to specify:
The roi.txt is specified within the ROI (Region of Interest) by the order of the four region side coordinates left, top, right, bottom, separated by spaces, for example:
Performance Tuning Recommendations
Based on the performance evaluation and analysis above, you may find that the performance result is not as expected, at this time you can refer to the Model Performance Tuning section, we provide suggestions and measures to improve the performance of the model for tuning attempts.
