TrainingExtensions/tensorflow/src/python/aimet_tensorflow/quantsim_config/quantsim_config.py
def _set_config_for_op(self, input_output_quantize_ops: QuantizerListType, op_config: OpType,
                           modified_quantize_ops: Dict[tf.Operation, Set], op: tf.Operation = None):
        """
        Set configurations for a specific op
        :param input_output_quantize_ops: Tuple containing 2 lists:
            - List of quantize ops to change if op's input quantizer setting is set
            - List of quantize ops to change if op's output quantizer setting is set
        :param op_config: Configuration for the op
        :param modified_quantize_ops: Dictionary of quantize ops mapping to set of settings that have been changed for
            that quantize op already.
        :param op: Quantize op to set config of
        """
        if ConfigDictKeys.IS_INPUT_QUANTIZED in op_config:
            self._modify_activation_quantize_op(input_output_quantize_ops, ConfigDictKeys.IS_INPUT_QUANTIZED,
                                                op_config[ConfigDictKeys.IS_INPUT_QUANTIZED], modified_quantize_ops)
        if ConfigDictKeys.IS_OUTPUT_QUANTIZED in op_config:
            self._modify_activation_quantize_op(input_output_quantize_ops, ConfigDictKeys.IS_OUTPUT_QUANTIZED,
                                                op_config[ConfigDictKeys.IS_OUTPUT_QUANTIZED], modified_quantize_ops)
        if ConfigDictKeys.IS_SYMMETRIC in op_config:
            self._modify_activation_quantize_op(input_output_quantize_ops, ConfigDictKeys.IS_SYMMETRIC,
                                                op_config[ConfigDictKeys.IS_SYMMETRIC], modified_quantize_ops)

        # Will only see this in the op_type section, not default
        if ConfigDictKeys.PARAMS in op_config:
            if op is None:
                logger.error('No module provided to set params for')
                raise AssertionError
            param_quantize_ops_dict, _ = self._op_to_quant_ops_dict[op]
            for param_name in param_quantize_ops_dict.keys():
                quantsim_param_name = MAP_TF_PARAM_NAME_TO_QUANTSIM_NAME.get(param_name, None)
                if quantsim_param_name is not None and quantsim_param_name in op_config[ConfigDictKeys.PARAMS]:
                    param_config = op_config[ConfigDictKeys.PARAMS][quantsim_param_name]
                    for param_quantize_op in param_quantize_ops_dict[param_name]:
                        self._set_config_for_param(param_quantize_op, param_config)

        Set configurations for a specific op
        :param input_output_quantize_ops: Tuple containing 2 lists:
            - List of quantize ops to change if op's input quantizer setting is set
            - List of quantize ops to change if op's output quantizer setting is set
        :param op_config: Configuration for the op
        :param modified_quantize_ops: Dictionary of quantize ops mapping to set of settings that have been changed for
            that quantize op already.
        :param op: Quantize op to set config of
        
Set configurations for a specific op
Set configurations for a specific op
def _set_config_for_op(self, input_output_quantize_ops: QuantizerListType, op_config: OpType,
                           modified_quantize_ops: Dict[tf.Operation, Set], op: tf.Operation = None):
        if ConfigDictKeys.IS_INPUT_QUANTIZED in op_config:
            self._modify_activation_quantize_op(input_output_quantize_ops, ConfigDictKeys.IS_INPUT_QUANTIZED,
                                                op_config[ConfigDictKeys.IS_INPUT_QUANTIZED], modified_quantize_ops)
        if ConfigDictKeys.IS_OUTPUT_QUANTIZED in op_config:
            self._modify_activation_quantize_op(input_output_quantize_ops, ConfigDictKeys.IS_OUTPUT_QUANTIZED,
                                                op_config[ConfigDictKeys.IS_OUTPUT_QUANTIZED], modified_quantize_ops)
        if ConfigDictKeys.IS_SYMMETRIC in op_config:
            self._modify_activation_quantize_op(input_output_quantize_ops, ConfigDictKeys.IS_SYMMETRIC,
                                                op_config[ConfigDictKeys.IS_SYMMETRIC], modified_quantize_ops)
        if ConfigDictKeys.PARAMS in op_config:
            if op is None:
                logger.error('No module provided to set params for')
                raise AssertionError
            param_quantize_ops_dict, _ = self._op_to_quant_ops_dict[op]
            for param_name in param_quantize_ops_dict.keys():
                quantsim_param_name = MAP_TF_PARAM_NAME_TO_QUANTSIM_NAME.get(param_name, None)
                if quantsim_param_name is not None and quantsim_param_name in op_config[ConfigDictKeys.PARAMS]:
                    param_config = op_config[ConfigDictKeys.PARAMS][quantsim_param_name]
                    for param_quantize_op in param_quantize_ops_dict[param_name]:
                        self._set_config_for_param(param_quantize_op, param_config)
def _set_config_for_op ( self , input_output_quantize_ops : QuantizerListType , op_config : OpType , modified_quantize_ops : Dict [ tf . Operation , Set ] , op : tf . Operation = None ) : if ConfigDictKeys . IS_INPUT_QUANTIZED in op_config : self . _modify_activation_quantize_op ( input_output_quantize_ops , ConfigDictKeys . IS_INPUT_QUANTIZED , op_config [ ConfigDictKeys . IS_INPUT_QUANTIZED ] , modified_quantize_ops ) if ConfigDictKeys . IS_OUTPUT_QUANTIZED in op_config : self . _modify_activation_quantize_op ( input_output_quantize_ops , ConfigDictKeys . IS_OUTPUT_QUANTIZED , op_config [ ConfigDictKeys . IS_OUTPUT_QUANTIZED ] , modified_quantize_ops ) if ConfigDictKeys . IS_SYMMETRIC in op_config : self . _modify_activation_quantize_op ( input_output_quantize_ops , ConfigDictKeys . IS_SYMMETRIC , op_config [ ConfigDictKeys . IS_SYMMETRIC ] , modified_quantize_ops ) if ConfigDictKeys . PARAMS in op_config : if op is None : logger . error ( 'No module provided to set params for' ) raise AssertionError param_quantize_ops_dict , _ = self . _op_to_quant_ops_dict [ op ] for param_name in param_quantize_ops_dict . keys ( ) : quantsim_param_name = MAP_TF_PARAM_NAME_TO_QUANTSIM_NAME . get ( param_name , None ) if quantsim_param_name is not None and quantsim_param_name in op_config [ ConfigDictKeys . PARAMS ] : param_config = op_config [ ConfigDictKeys . PARAMS ] [ quantsim_param_name ] for param_quantize_op in param_quantize_ops_dict [ param_name ] : self . _set_config_for_param ( param_quantize_op , param_config )
Set configurations for a specific op
Set configurations for a specific op
"""
        Set configurations for a specific op
        :param input_output_quantize_ops: Tuple containing 2 lists:
            - List of quantize ops to change if op's input quantizer setting is set
            - List of quantize ops to change if op's output quantizer setting is set
        :param op_config: Configuration for the op
        :param modified_quantize_ops: Dictionary of quantize ops mapping to set of settings that have been changed for
            that quantize op already.
        :param op: Quantize op to set config of
        """ # Will only see this in the op_type section, not default
self
input_output_quantize_ops
QuantizerListType
Tuple containing 2 lists:
List of quantize ops to change if op's input quantizer setting is set
List of quantize ops to change if op's output quantizer setting is set
Tuple containing 2 lists : List of quantize ops to change if op ' s input quantizer setting is set List of quantize ops to change if op ' s output quantizer setting is set
op_config
OpType
Configuration for the op
Configuration for the op
modified_quantize_ops
Dict[tf.Operation, Set]
Dictionary of quantize ops mapping to set of settings that have been changed for
that quantize op already.
Dictionary of quantize ops mapping to set of settings that have been changed for that quantize op already .
op
tf.Operation
Quantize op to set config of
Quantize op to set config of