Modifying the Model Definition - 3.5 English

Vitis AI User Guide (UG1414)

Document ID
UG1414
Release Date
2023-09-28
Version
3.5 English
To enable quantization for a PyTorch model, it is necessary to modify the model definition to ensure it meets the following condition. Vitis AI GitHub provides an example.
  1. The model intended for quantization must contain only the forward method. All other functions, which typically serve as pre-processing and post-processing operations, should be moved outside the model or placed in a derived class. Failure to do so might result in unexpected behavior when forwarding the quantized module, as the API removes these functions in the quantized module.
  2. The float model should pass the JIT trace test. Set the floating-point module to evaluation status, then use the torch.jit.trace function to test the float model. For more details, refer to example/jupyter_notebook/jit_trace_test/jit_trace_test.ipynb.
The most common operators in PyTorch are supported in vai_q_pytorch. For more information, go to doc/support_op.md.