afe.ir.transform.calibration_transforms
Attributes
Classes
Inserts NodeObservers into AwesomeNet's nodes. NodeObservers will not be added |
|
Inserts NodeObservers that collect per-channel statistics in AwesomeNet's nodes. |
|
Remove NodeObservers from AwesomeNet's nodes. This is needed in order to remove |
|
Calibrates an AwesomeNet. |
|
Calibrates an AwesomeNet for analyses that require per-channel information. |
Functions
|
Calibrate the AwesomeNode and get the (min, max) dynamic range. |
|
Run per-channel calibration on the AwesomeNode. |
Module Contents
- afe.ir.transform.calibration_transforms.calibrate_node(node: afe.ir.node.AwesomeNode, inputs: Dict[afe.ir.defines.InputName, afe.ir.sima_ir.SiMaIRTensorTypes], node_outputs: Dict[afe.ir.defines.NodeName, afe.ir.sima_ir.SiMaIRTensorTypes])[source]
Calibrate the AwesomeNode and get the (min, max) dynamic range.
- Parameters:
node – AwesomeNode. The node to be calibrated.
inputs – Dict[InputName, Any]. Dictionary containing AwesomeNode inputs.
node_outputs – Dict[NodeName, SiMaIRTensorTypes]. Dictionary containing AwesomeNode outputs.
- afe.ir.transform.calibration_transforms.per_channel_calibrate_node(node: afe.ir.node.AwesomeNode, inputs: Dict[afe.ir.defines.InputName, afe.ir.sima_ir.SiMaIRTensorTypes], node_outputs: Dict[afe.ir.defines.NodeName, afe.ir.sima_ir.SiMaIRTensorTypes])[source]
Run per-channel calibration on the AwesomeNode. This calibration is for SmoothQuant and channel equalization. It does not collect all information that is needed for quantization.
- Parameters:
node – AwesomeNode. The node to be calibrated.
inputs – Dict[InputName, Any]. Dictionary containing AwesomeNode inputs.
node_outputs – Dict[NodeName, SiMaIRTensorTypes]. Dictionary containing AwesomeNode outputs.
- class afe.ir.transform.calibration_transforms.InsertNodeObservers(calibration_method: afe.apis.defines.CalibrationMethod)[source]
Inserts NodeObservers into AwesomeNet’s nodes. NodeObservers will not be added to nodes that don’t use information obtained from calibration pass, but obtain quantization parameters based on the quantization parameters of its inputs.
- Parameters:
calibration_method – CalibrationMethod used in calibration. Determines the type of observers which shall be created. See CalibrationMethod Enum class for supported values.
percentile_value – If the Histogram percentile is being used, percentage of values to keep.
- class afe.ir.transform.calibration_transforms.InsertPerChannelNodeObservers[source]
Inserts NodeObservers that collect per-channel statistics in AwesomeNet’s nodes. To save analysis time, NodeObservers will only be added to layers where the statistics are useful for SmoothQuant and channel equalization.
- class afe.ir.transform.calibration_transforms.RemoveNodeObservers[source]
Remove NodeObservers from AwesomeNet’s nodes. This is needed in order to remove PyTorch infrastructure which is no longer needed from AwesomeNet’s nodes.
- class afe.ir.transform.calibration_transforms.Calibrate(length_hint: int | None, dataset: Iterable[Dict[str, numpy.ndarray]])[source]
Calibrates an AwesomeNet.
- Parameters:
length_hint – If not None, gives the number of items in the data set. This is used for progress reporting and it does not affect the number of items used for calibration.
dataset – The input data set for calibration.