afe.core.quantize_networks

Functions

quantize_network(→ None)

Quantizes the AwesomeNet. If the AwesomeNet has not been calibrated, run the calibration first.

Module Contents

afe.core.quantize_networks.quantize_network(net: afe.ir.net.AwesomeNet, model_config: afe.core.configs.ModelConfigs, opt_config: afe.core.configs.OptimizationConfigs, input_generator: sima_utils.data.data_generator.DataGenerator | Iterable[Dict[afe.ir.defines.NodeName, numpy.ndarray]] | None = None, dump_to_files: bool = False, custom_quantization_configs: Dict[afe.ir.defines.NodeName, Dict[str, Any]] | None = None) None[source]

Quantizes the AwesomeNet. If the AwesomeNet has not been calibrated, run the calibration first. Save the YAML, JSON, and npz if the SIMA_AFE_SAVED_FILES environmental variables is set to 1 or dump_to_files input argument has been set to True.

Parameters:
  • net – an AwesomeNet

  • model_config – A ModelConfigs instance containing model related information and status.

  • opt_config – A OptimizationConfigs instance containing quantization scheme information.

  • input_generator – Source of input values for calibration. May be None if network is already calibrated.

  • dump_to_files – Flag enabling writing the quantized AwesomeNet to .npz file and configs to .yaml file

  • custom_quantization_configs – Optional[Dict[NodeName, Dict[str, Any]]]. A dictionary using NodeName as keys. The value to each key is a dictionary of the AwesomeQuantAttr’s field names and sets target configuration.

Example

The example shows how a custom_quantization_configs looks like to config the output_int32 field in a Conv2DQuantAttrs in a output conv2d_add node to True.

custom_quantization_configs = {“MLA_1/conv2d_add_84”: {“output_int32”: True}}