KD_Lib.Quantization.dynamic

KD_Lib.Quantization.dynamic.dynamic_quantization module

class KD_Lib.Quantization.dynamic.dynamic_quantization.Dynamic_Quantizer(model, test_loader, qconfig_spec=None)[source]

Bases: KD_Lib.Quantization.common.base_class.Quantizer

Implementation of Dynamic Quantization for PyTorch models.

Parameters:
  • model (torch.nn.Module) – Model that needs to be quantized
  • qconfig_spec (Qconfig_spec) – Qconfig spec
  • test_loader (torch.utils.data.DataLoader) – DataLoader used for testing
quantize(dtype=torch.qint8, mapping=None)[source]

Function used for quantization

Parameters:
  • dtype (torch.dtype) – dtype for quantized modules
  • mapping (mapping) – maps type of a submodule to a type of corresponding dynamically quantized version with which the submodule needs to be replaced