megengine.quantization.quantize_qat

quantize_qat(module, inplace=True, qconfig=ema_fakequant_qconfig, mapping=None)[source]

Recursively convert float Module to QATModule through apply and set qconfig relatively.

Parameters
  • module (Module) – root module to do convert recursively.

  • inplace (bool) – whether to convert submodules in-place.

  • qconfig (QConfig) – an instance of QConfig to be set as submodules’ quant config. Default: ema_fakequant_qconfig.

  • mapping (Optional[dict]) – a dict indicating how to convert custom modules from Module to QATModule. Will be combined with internal default convert mapping dict.

Returns

Module. Quantized module.

Return type

Return type

Examples

>>> import megengine.quantization as Q
>>> model = Net()                                           
>>> Q.quantize_qat(model, qconfig=Q.ema_fakequant_qconfig)