This function gets the float model for QAT.
vitis_quantize.VitisQuantizer.get_qat_model( init_quant=False, calib_dataset=None, calib_batch_size=None, calib_steps=None, train_with_bn=False, freeze_bn_delay=-1, replace_sigmoid=True, replace_relu6=True, include_cle=True, cle_steps=10, forced_cle=False)
boolobject to notify whether or not to run initial quantization before QAT. Running an initial PTQ quantization yields an improved initial state for the quantizer parameters, especially for 8bit_tqt strategy. Otherwise, the training may not converge.
np.numpyobject, the representative dataset for calibration. Must be set when "init_quant" is set
True. You can use full or part of eval_dataset, train_dataset or other datasets as calib_dataset.
- An int object, the total number of steps for initial PTQ.
Ignored with the default value of None. If "calib_dataset" is a
tf.data dataset, generator or
keras.utils.Sequenceinstance and steps is None, calibration will run until the dataset is exhausted. This argument is not supported with array inputs.
- An int object, the number of samples per batch for initial
PTQ. If the "calib_dataset" is in the form of a dataset, generator or
keras.utils.Sequenceinstances, the batch size is controlled by the dataset itself. If the "calib_dataset" is in the form of a
numpy.arrayobject, the default batch size is 32.
boolobject, whether to keep bn layers during QAT. If set to True, bn parameters are updated during quantize-aware training and help the model to converge. These trained bn layers are then fused into previous convolution-like layers in the get_deploy_model() function. If the float model has no bn layers, this option has have no affect. The default value is False.
- An int object, the train steps before freezing the bn parameters. After the delayed steps, model will switch inference bn parameters to avoid instability in training. Only take effect when train_with_bn is True. Default value is -1, which means never do bn freezing.
boolobject, whether to replace the Activation(activation='sigmoid') layers into hard sigmoid layers and do quantization. If not, the sigmoid layers will be left unquantized and will be scheduled on CPU.
boolobject, whether to replace the Relu6 layers with Relu layers.
boolobject, whether to do Cross Layer Equalization before quantization.
- An int object, the iteration steps to do Cross Layer Equalization.
boolobject, whether to do forced Cross Layer Equalization for relu6 layers.