TrainingExtensions/common/src/python/aimet_common/quantsim_config/json_config_importer.py
def _validate_semantics(quantsim_config: ConfigDictType):
    """
    Validate config dict syntax, ensuring keys and values are as expected.  Throw an exception if anything is amiss.
    :param quantsim_config: Configuration dictionary to validate
    """

    # Currently, for default configs, only IS_OUTPUT_QUANTIZED = True is supported
    default_op_configs = quantsim_config[ConfigDictKeys.DEFAULTS][ConfigDictKeys.OPS]
    if ConfigDictKeys.IS_INPUT_QUANTIZED in default_op_configs:
        logger.error('Currently IS_INPUT_QUANTIZED setting in default configs is not supported')
        raise NotImplementedError
    if ConfigDictKeys.IS_OUTPUT_QUANTIZED in default_op_configs and not \
            default_op_configs[ConfigDictKeys.IS_OUTPUT_QUANTIZED]:
        logger.error('Currently IS_OUTPUT_QUANTIZED false setting in default configs is not supported')
        raise NotImplementedError

    # Currently, for op_type configs, only IS_INPUT_QUANTIZED = True is supported
    op_type_configs = quantsim_config[ConfigDictKeys.OP_TYPE]
    for op_type_config in op_type_configs.values():
        if ConfigDictKeys.IS_INPUT_QUANTIZED in op_type_config and not \
                op_type_config[ConfigDictKeys.IS_INPUT_QUANTIZED]:
            logger.error('IS_INPUT_QUANTIZED false in op configs is currently unsupported.')
            raise NotImplementedError

    # For model input configs, only IS_INPUT_QUANTIZED = True is supported
    model_input_configs = quantsim_config[ConfigDictKeys.MODEL_INPUT]
    if ConfigDictKeys.IS_INPUT_QUANTIZED in model_input_configs:
        if not model_input_configs[ConfigDictKeys.IS_INPUT_QUANTIZED]:
            logger.error('IS_INPUT_QUANTIZED for model input can only be set to True')
            raise NotImplementedError

    # For model output configs, only IS_OUTPUT_QUANTIZED = True is supported
    model_output_configs = quantsim_config[ConfigDictKeys.MODEL_OUTPUT]
    if ConfigDictKeys.IS_OUTPUT_QUANTIZED in model_output_configs:
        if not model_output_configs[ConfigDictKeys.IS_OUTPUT_QUANTIZED]:
            logger.error('IS_OUTPUT_QUANTIZED for model output can only be set to True')
            raise NotImplementedError

    Validate config dict syntax, ensuring keys and values are as expected.  Throw an exception if anything is amiss.
    :param quantsim_config: Configuration dictionary to validate
    
Validate config dict syntax, ensuring keys and values are as expected.  Throw an exception if anything is amiss.
Validate config dict syntax ensuring keys and values are as expected . Throw an exception if anything is amiss .
def _validate_semantics(quantsim_config: ConfigDictType):
    default_op_configs = quantsim_config[ConfigDictKeys.DEFAULTS][ConfigDictKeys.OPS]
    if ConfigDictKeys.IS_INPUT_QUANTIZED in default_op_configs:
        logger.error('Currently IS_INPUT_QUANTIZED setting in default configs is not supported')
        raise NotImplementedError
    if ConfigDictKeys.IS_OUTPUT_QUANTIZED in default_op_configs and not \
            default_op_configs[ConfigDictKeys.IS_OUTPUT_QUANTIZED]:
        logger.error('Currently IS_OUTPUT_QUANTIZED false setting in default configs is not supported')
        raise NotImplementedError
    op_type_configs = quantsim_config[ConfigDictKeys.OP_TYPE]
    for op_type_config in op_type_configs.values():
        if ConfigDictKeys.IS_INPUT_QUANTIZED in op_type_config and not \
                op_type_config[ConfigDictKeys.IS_INPUT_QUANTIZED]:
            logger.error('IS_INPUT_QUANTIZED false in op configs is currently unsupported.')
            raise NotImplementedError
    model_input_configs = quantsim_config[ConfigDictKeys.MODEL_INPUT]
    if ConfigDictKeys.IS_INPUT_QUANTIZED in model_input_configs:
        if not model_input_configs[ConfigDictKeys.IS_INPUT_QUANTIZED]:
            logger.error('IS_INPUT_QUANTIZED for model input can only be set to True')
            raise NotImplementedError
    model_output_configs = quantsim_config[ConfigDictKeys.MODEL_OUTPUT]
    if ConfigDictKeys.IS_OUTPUT_QUANTIZED in model_output_configs:
        if not model_output_configs[ConfigDictKeys.IS_OUTPUT_QUANTIZED]:
            logger.error('IS_OUTPUT_QUANTIZED for model output can only be set to True')
            raise NotImplementedError
def _validate_semantics ( quantsim_config : ConfigDictType ) : default_op_configs = quantsim_config [ ConfigDictKeys . DEFAULTS ] [ ConfigDictKeys . OPS ] if ConfigDictKeys . IS_INPUT_QUANTIZED in default_op_configs : logger . error ( 'Currently IS_INPUT_QUANTIZED setting in default configs is not supported' ) raise NotImplementedError if ConfigDictKeys . IS_OUTPUT_QUANTIZED in default_op_configs and not default_op_configs [ ConfigDictKeys . IS_OUTPUT_QUANTIZED ] : logger . error ( 'Currently IS_OUTPUT_QUANTIZED false setting in default configs is not supported' ) raise NotImplementedError op_type_configs = quantsim_config [ ConfigDictKeys . OP_TYPE ] for op_type_config in op_type_configs . values ( ) : if ConfigDictKeys . IS_INPUT_QUANTIZED in op_type_config and not op_type_config [ ConfigDictKeys . IS_INPUT_QUANTIZED ] : logger . error ( 'IS_INPUT_QUANTIZED false in op configs is currently unsupported.' ) raise NotImplementedError model_input_configs = quantsim_config [ ConfigDictKeys . MODEL_INPUT ] if ConfigDictKeys . IS_INPUT_QUANTIZED in model_input_configs : if not model_input_configs [ ConfigDictKeys . IS_INPUT_QUANTIZED ] : logger . error ( 'IS_INPUT_QUANTIZED for model input can only be set to True' ) raise NotImplementedError model_output_configs = quantsim_config [ ConfigDictKeys . MODEL_OUTPUT ] if ConfigDictKeys . IS_OUTPUT_QUANTIZED in model_output_configs : if not model_output_configs [ ConfigDictKeys . IS_OUTPUT_QUANTIZED ] : logger . error ( 'IS_OUTPUT_QUANTIZED for model output can only be set to True' ) raise NotImplementedError
Validate config dict syntax, ensuring keys and values are as expected.
Validate config dict syntax ensuring keys and values are as expected .
"""
    Validate config dict syntax, ensuring keys and values are as expected.  Throw an exception if anything is amiss.
    :param quantsim_config: Configuration dictionary to validate
    """ # Currently, for default configs, only IS_OUTPUT_QUANTIZED = True is supported # Currently, for op_type configs, only IS_INPUT_QUANTIZED = True is supported # For model input configs, only IS_INPUT_QUANTIZED = True is supported # For model output configs, only IS_OUTPUT_QUANTIZED = True is supported
quantsim_config
ConfigDictType
Configuration dictionary to validate
Configuration dictionary to validate