afe.apis.defines ================ .. py:module:: afe.apis.defines .. autoapi-nested-parse:: This file contains definitions of the types exposed by the development API for AFE. Attributes ---------- .. autoapisummary:: afe.apis.defines.InputValues afe.apis.defines.gen1_target afe.apis.defines.gen2_target afe.apis.defines.gen_custom_target afe.apis.defines.BT_COLOR_COEFF afe.apis.defines.YUV2RGB_FULL_RANGE_CONSTANTS afe.apis.defines.default_quantization afe.apis.defines.int16_quantization Classes ------- .. autoapisummary:: afe.apis.defines.ExceptionFuncType afe.apis.defines.ColorSpaceStandard afe.apis.defines.ColorConversion afe.apis.defines.ChromaSampling afe.apis.defines.ResizeMethod afe.apis.defines.ResizeDepositLocation afe.apis.defines.CalibrationMethod afe.apis.defines.MinMaxMethod afe.apis.defines.HistogramMSEMethod afe.apis.defines.MovingAverageMinMaxMethod afe.apis.defines.HistogramEntropyMethod afe.apis.defines.HistogramPercentileMethod afe.apis.defines.SkipCalibration afe.apis.defines.QuantizationScheme afe.apis.defines.QuantizationParams Functions --------- .. autoapisummary:: afe.apis.defines.default_calibration afe.apis.defines.quantization_scheme afe.apis.defines.bfloat16_scheme Module Contents --------------- .. py:data:: InputValues .. py:data:: gen1_target .. py:data:: gen2_target .. py:data:: gen_custom_target .. py:class:: ExceptionFuncType(*args, **kwds) Create a collection of name/value pairs. Example enumeration: >>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3 Access them by: - attribute access: >>> Color.RED - value lookup: >>> Color(1) - name lookup: >>> Color['RED'] Enumerations can be iterated over, and know how many members they have: >>> len(Color) 3 >>> list(Color) [, , ] Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details. .. py:attribute:: LOADED_NET_LOAD .. py:attribute:: LOADED_NET_EXECUTE .. py:attribute:: LOADED_NET_QUANTIZE .. py:attribute:: LOADED_NET_CONVERT .. py:attribute:: MODEL_EXECUTE .. py:attribute:: MODEL_SAVE .. py:attribute:: MODEL_LOAD .. py:attribute:: MODEL_COMPILE .. py:attribute:: MODEL_CREATE_AUXILIARY .. py:attribute:: MODEL_COMPOSE .. py:attribute:: MODEL_EVALUATE .. py:attribute:: MODEL_PERFORMANCE .. py:attribute:: GENERATE_ELF_FILES .. py:attribute:: QUANTIZATION_ERROR_ANALYSIS .. py:class:: ColorSpaceStandard Color space standards for YUV and RGB conversion. BT601 is for SD video; BT709 is for HD video; BT2020 is for HDR. .. py:attribute:: BT601 :value: 'BT601' .. py:attribute:: BT709 :value: 'BT709' .. py:attribute:: BT2020 :value: 'BT2020' .. py:data:: BT_COLOR_COEFF :type: Dict[ColorSpaceStandard, List[float]] .. py:data:: YUV2RGB_FULL_RANGE_CONSTANTS :type: Dict[str, List[float]] .. py:class:: ColorConversion Color conversion direction. .. py:attribute:: YUV2RGB :value: 'YUV2RGB' .. py:attribute:: RGB2YUV :value: 'RGB2YUV' .. py:attribute:: BGR2RGB :value: 'BGR2RGB' .. py:attribute:: RGB2BGR :value: 'RGB2BGR' .. py:class:: ChromaSampling Chroma sub-sampling representation. .. py:attribute:: NV12 :value: 'NV12' .. py:attribute:: YUV420 :value: 'YUV420' .. py:attribute:: YUV422 :value: 'YUV422' .. py:class:: ResizeMethod Interpolation method used in resize transform. .. py:attribute:: LINEAR :value: 'linear' .. py:attribute:: NEAREST :value: 'nearest' .. py:attribute:: AREA :value: 'area' .. py:attribute:: CUBIC :value: 'cubic' .. py:class:: ResizeDepositLocation Deposit location of resized image in padded frame. .. py:attribute:: TOPLEFT :value: 'topleft' .. py:attribute:: CENTER :value: 'center' .. py:attribute:: BOTTOMRIGHT :value: 'bottomright' .. py:class:: CalibrationMethod .. py:property:: name .. py:method:: from_str(method: str) :staticmethod: .. py:class:: MinMaxMethod .. py:class:: HistogramMSEMethod(num_bins) .. py:attribute:: num_bins :type: int .. py:class:: MovingAverageMinMaxMethod .. py:class:: HistogramEntropyMethod(num_bins) .. py:attribute:: num_bins :type: int .. py:class:: HistogramPercentileMethod(percentile_value, num_bins) .. py:attribute:: percentile_value :type: float .. py:attribute:: num_bins :type: int .. py:class:: SkipCalibration Directive to skip calibration. .. py:function:: default_calibration() -> CalibrationMethod .. py:class:: QuantizationScheme Quantization scheme. :param asymmetric: Whether to use asymmetric quantization. :param per_channel: Whether to use per-channel quantization. :param bits: Number of bits of precision to use in the quantized representation :param bf16: Whether to use bfloat16. If True, then asymmetric, per_channel, and bits are ignored. .. py:attribute:: asymmetric :type: bool .. py:attribute:: per_channel :type: bool .. py:attribute:: bits :type: int :value: 8 .. py:attribute:: bf16 :type: bool :value: False .. py:function:: quantization_scheme(asymmetric: bool, per_channel: bool, bits: int = 8) -> QuantizationScheme Constructs quantization scheme. .. py:function:: bfloat16_scheme() -> QuantizationScheme Constructs a bfloat16 quantization scheme. It directs the compiler to use bfloat16 instead of integer quantization. .. py:class:: QuantizationParams Parameters controlling how to quantize a network. :param calibration_method: Calibration method. :param activation_quantization_scheme: Quantization scheme for activation tensors. :param weight_quantization_scheme: Quantization scheme for weights tensors. :param requantization_mode: A way of doing quantized arithmetic. :param node_names: Nodes to prevent from quantizing. :param custom_quantization_configs: Dictionary setting the node's custom quantization options. :param biascorr_type: Selection of bias correction: regular/iterative/none :param channel_equalization: If True, channel equalization is enabled. :param smooth_quant: If True, smooth quant is enabled. :param prefer_int8_udf: If True int8 is used in UDF if False int16 is used. .. py:attribute:: calibration_method :type: CalibrationMethod .. py:attribute:: activation_quantization_scheme :type: QuantizationScheme .. py:attribute:: weight_quantization_scheme :type: QuantizationScheme .. py:attribute:: requantization_mode :type: afe.ir.defines.RequantizationMode .. py:attribute:: node_names :type: Set[str] .. py:attribute:: custom_quantization_configs :type: Optional[Dict[afe.ir.defines.NodeName, Dict[str, Any]]] :value: None .. py:attribute:: biascorr_type :type: afe.ir.defines.BiasCorrectionType .. py:attribute:: channel_equalization :type: bool :value: False .. py:attribute:: smooth_quant :type: bool :value: False .. py:attribute:: prefer_int8_udf :type: bool :value: True .. py:method:: with_calibration(method: CalibrationMethod) -> QuantizationParams .. py:method:: with_activation_quantization(scheme: QuantizationScheme) -> QuantizationParams .. py:method:: with_weight_quantization(scheme: QuantizationScheme) -> QuantizationParams .. py:method:: with_requantization_mode(requantization_mode: afe.ir.defines.RequantizationMode) .. py:method:: with_unquantized_nodes(node_names: Set[str]) -> QuantizationParams .. py:method:: with_custom_quantization_configs(custom_quantization_configs: Dict[afe.ir.defines.NodeName, Dict[str, Any]]) .. py:method:: with_bias_correction(enable: bool | afe.ir.defines.BiasCorrectionType = True) .. py:method:: with_channel_equalization(enable: bool = True) .. py:method:: with_smooth_quant(enable: bool = True) .. py:method:: with_prefer_int8_udf(mode: bool = True) .. py:data:: default_quantization :type: QuantizationParams .. py:data:: int16_quantization :type: QuantizationParams