(Optional) Dumping the Simulation Results - 1.3 English

Vitis AI User Guide (UG1414)

Document ID
UG1414
Release Date
2021-02-03
Version
1.3 English
Sometimes after deploying the quantized model, it is necessary to compare the simulation results on the CPU/GPU and the output values on the DPU. You can use the VitisQuantizer.dump_model API of vai_q_tensorflow2 to dump the simulation results with the quantized_model.
from tensorflow_model_optimization.quantization.keras import vitis_quantize
with vitis_quantize.quantize_scope():
    quantized_model = keras.models.load_model('./quantized_model.h5')
    vitis_quantize.VitisQuantizer.dump_model(quantized_model, dump_dataset, output_dir='./dump_results')
Note: The batch_size of the dump_dataset should be set to 1 for DPU debugging.

Dump results are generated in ${dump_output_dir} after the command has successfully executed. Results for weights and activation of each layer are saved separately in the folder. For each quantized layer, results are saved in *.bin and *.txt formats. If the output of the layer is not quantized (such as for the softmax layer), the float activation results are saved in *_float.bin and *_float.txt. The / symbol is replaced by _ for simplicity. Examples for dumping results are shown in the following table.

Table 1. Example of Dumping Results
Batch No. Quantized Layer Name Saved files
Weights Biases Activation
1 Yes resnet_v1_50/conv1

{output_dir}/dump_results_weights/quant_resnet_v1_50_conv1_kernel.bin

{output_dir}/dump_results_weights/quant_resnet_v1_50_conv1_kernel.txt

{output_dir}/dump_results_weights/quant_resnet_v1_50_conv1_bias.bin

{output_dir}/dump_results_weights/quant_resnet_v1_50_conv1_bias.txt

{output_dir}/dump_results_0/quant_resnet_v1_50_conv1.bin

{output_dir}/dump_results_0/quant_resnet_v1_50_conv1.txt

2 No resnet_v1_50/softmax N/A N/A

{output_dir}/dump_results_0/quant_resnet_v1_50_softmax_float.bin

{output_dir}/dump_results_0/quant_resnet_v1_50_softmax_float.txt