aihwkit.nn.low_precision_modules.conversion_utils module

Utility funcitons for converting a module to its quantized counterpart

aihwkit.nn.low_precision_modules.conversion_utils.append_default_conversions(quantization_map)[source]

Appends the default conversions defined in the DEFAULT_CONVERSIONS dictionary in the QuantizationMap datastructure. If a conversion for a specific layer is already defined in the datastructure, it skips it.

As for the conversion’s QuantizationConfig, it utilizes the default one defined in the quantization_map.default_qconfig field.

Parameters:

quantization_map (QuantizationMap) – The QuantizationMap instance to append the default conversions

Return type:

None

aihwkit.nn.low_precision_modules.conversion_utils.get_module_args(module, activation=None)[source]

Get the arguments from a pytorch module to provide it to the initialization function of the quantized modules. The way to retrieve the arguments for each type of module are defined with functions defined inside this functions, with the convention get_{module_type}_args

Parameters:
  • module (Module) – The module to extract the arguments from

  • activation (Optional[Module], optional) – The activation function for the QuantizationHijacker if applicable, by default None

Raises:

ValueError – If the function has not been tought how to handle a given module.

Return type:

dict