The construction function of class VitisQuantizer
.
vitis_quantize.VitisQuantizer(
float_model,
quantize_strategy='pof2s',
custom_quantize_strategy=None,
custom_objects={})
Arguments
- float_model
- A
tf.keras.Model
object containing the configurations for quantization. - quantize_strategy
- A string object of the quantize strategy type. Available values are
pof2s
,pof2s_tqt
,fs
andfsx
.pof2s
is the default strategy designed for DPU. It uses a power-of-2 scale quantizer and uses the Straight-Through-Estimator for QAT.pof2s_tqt
is a QAT-only strategy introduced in Vitis AI 1.4, which uses trained threshold in quantizers and might generate better results for power-of-2 scale QAT.fs
is a quantization strategy introduced in Vitis AI 2.5. It performs float scale quantization for inputs and weights of Conv2D, DepthwiseConv2D, Conv2DTranspose, and Dense layers.fsx
quantization strategy performs quantization for more layer types than the fs quantize strategy, such as Add, MaxPooling2D, and AveragePooling2D. Moreover, it also quantizes the biases and activations.Note: pof2s_tqt strategy should only be used in QAT and together withinit_quant=True
to get the best performance.Note:fs
andfsx
strategies are designed for target devices with floating-point supports. DPU does not have floating-point support now, so models quantized with these quantize strategies cannot be deployed to DPU. - custom_quantize_strategy
- String. The file path of the custom quantize strategy JSON file.
- custom_objects
- Dict. Mapping names (strings) to custom classes or functions.