afe.ir.transform.calibration_transforms ======================================= .. py:module:: afe.ir.transform.calibration_transforms Attributes ---------- .. autoapisummary:: afe.ir.transform.calibration_transforms.DONE Classes ------- .. autoapisummary:: afe.ir.transform.calibration_transforms.InsertNodeObservers afe.ir.transform.calibration_transforms.InsertPerChannelNodeObservers afe.ir.transform.calibration_transforms.RemoveNodeObservers afe.ir.transform.calibration_transforms.Calibrate afe.ir.transform.calibration_transforms.CalibratePerChannel Functions --------- .. autoapisummary:: afe.ir.transform.calibration_transforms.calibrate_node afe.ir.transform.calibration_transforms.per_channel_calibrate_node Module Contents --------------- .. py:data:: DONE .. py:function:: 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]) Calibrate the AwesomeNode and get the (min, max) dynamic range. :param node: AwesomeNode. The node to be calibrated. :param inputs: Dict[InputName, Any]. Dictionary containing AwesomeNode inputs. :param node_outputs: Dict[NodeName, SiMaIRTensorTypes]. Dictionary containing AwesomeNode outputs. .. py:function:: 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]) 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. :param node: AwesomeNode. The node to be calibrated. :param inputs: Dict[InputName, Any]. Dictionary containing AwesomeNode inputs. :param node_outputs: Dict[NodeName, SiMaIRTensorTypes]. Dictionary containing AwesomeNode outputs. .. py:class:: InsertNodeObservers(calibration_method: afe.apis.defines.CalibrationMethod) 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. :param calibration_method: CalibrationMethod used in calibration. Determines the type of observers which shall be created. See CalibrationMethod Enum class for supported values. :param percentile_value: If the Histogram percentile is being used, percentage of values to keep. .. py:class:: InsertPerChannelNodeObservers 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. .. py:class:: RemoveNodeObservers Remove NodeObservers from AwesomeNet's nodes. This is needed in order to remove PyTorch infrastructure which is no longer needed from AwesomeNet's nodes. .. py:class:: Calibrate(length_hint: Optional[int], dataset: Iterable[Dict[str, numpy.ndarray]]) Calibrates an AwesomeNet. :param 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. :param dataset: The input data set for calibration. .. py:class:: CalibratePerChannel(length_hint: Optional[int], dataset: Iterable[Dict[str, numpy.ndarray]]) Calibrates an AwesomeNet for analyses that require per-channel information. This calibration pass is specialized for SmoothQuant and channel equalization.