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)
Arguments
- init_quant
- A
bool
object 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. - calib_dataset
- A
tf.data.Dataset
,keras.utils.Sequence
ornp.numpy
object, the representative dataset for calibration. Must be set when "init_quant" is setTrue
. You can use full or part of eval_dataset, train_dataset or other datasets as calib_dataset. - calib_steps
- 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 orkeras.utils.Sequence
instance and steps is None, calibration will run until the dataset is exhausted. This argument is not supported with array inputs. - calib_batch_size
- 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.Sequence
instances, the batch size is controlled by the dataset itself. If the "calib_dataset" is in the form of anumpy.array
object, the default batch size is 32. - train_with_bn
- A
bool
object, whether to keep bn layers during QAT. - freeze_bn_delay
- An int object, the train steps before freezing the bn parameters. Default value is -1, which means never do bn freezing.
- replace_sigmoid
- A
bool
object, 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. - replace_relu6
- A
bool
object, whether to replace the Relu6 layers with Relu layers. - include_cle
- A
bool
object, whether to do Cross Layer Equalization before quantization. - cle_steps
- An int object, the iteration steps to do Cross Layer Equalization.
- forced_cle
- A
bool
object, whether to do forced Cross Layer Equalization for relu6 layers.