QuantWeightPass¶
- class paddle.fluid.contrib.slim.quantization.quantization_pass. QuantWeightPass ( scope, place, bias_correction=False, quant_bits=8, save_int_weight=True ) [source]
-
quant weights and remove weights input quantize_linear node. for example: weight -> quant -> dequant -> conv2d will be frozen into weight -> dequant -> conv2d, and weight will be scaled offline.
- Parameters
-
scope (paddle.Scope) – scope is used to get the weight tensor values.
place (paddle.CPUPlace|paddle.CUDAPlace|str) – place is used to restore the weight tensors. If it’s string, It can be
cpu
, andgpu:x
, wherex
is the index of the GPUs.bias_correction (bool) – whether use bias correction for post-training quantization. https://arxiv.org/abs/1810.05723.
quant_bits (int, optional) – quantization bit number for weight. Default is 8.
save_int_weight (bool, optional) – Whether the type saving the weight is int. Default is True.
Examples