neural_compressor.common.base_config

The base config.

Classes

ConfigRegistry

A registry for managing configuration classes for different algorithms within specific frameworks.

BaseConfig

The base config for all algorithm configs.

ComposableConfig

A class representing a composable configuration.

Functions

register_config(framework_name, algo_name[, priority])

Register config decorator.

get_all_config_set_from_config_registry(...)

Retrieves all the configuration sets from the config registry for a given framework name.

register_supported_configs_for_fwk(fwk_name)

Register supported configs for specific framework.

Module Contents

class neural_compressor.common.base_config.ConfigRegistry[source]

A registry for managing configuration classes for different algorithms within specific frameworks.

neural_compressor.common.base_config.register_config(framework_name: str, algo_name: str, priority: float | int = 0)[source]

Register config decorator.

The register the configuration classes for different algorithms within specific frameworks.

Usage example:

@register_config(framework_name=FRAMEWORK_NAME, algo_name=ExampleAlgorithm, priority=100) class ExampleAlgorithmConfig:

# Configuration details for the ExampleAlgorithm

Parameters:
  • framework_name – the framework name.

  • algo_name – the algorithm name.

  • priority – the priority of the configuration. A larger number indicates a higher priority, which will be tried first at the auto-tune stage. Defaults to 0.

class neural_compressor.common.base_config.BaseConfig(white_list: List[neural_compressor.common.utils.OP_NAME_OR_MODULE_TYPE] | None = DEFAULT_WHITE_LIST)[source]

The base config for all algorithm configs.

name[source]

The name of the config.

Type:

str

params_list[source]

The list of tunable parameters in the config.

Type:

list

class neural_compressor.common.base_config.ComposableConfig(configs: List[BaseConfig])[source]

A class representing a composable configuration.

This class allows for composing multiple configurations together by using the + operator.

Parameters:

configs (List[BaseConfig]) – A list of base configurations to be composed.

config_list[source]

The list of base configurations.

Type:

List[BaseConfig]

neural_compressor.common.base_config.get_all_config_set_from_config_registry(fwk_name: str) BaseConfig | List[BaseConfig][source]

Retrieves all the configuration sets from the config registry for a given framework name.

Parameters:

fwk_name (str) – The name of the framework.

Returns:

The configuration set(s) for the given framework name.

Return type:

Union[BaseConfig, List[BaseConfig]]

neural_compressor.common.base_config.register_supported_configs_for_fwk(fwk_name: str)[source]

Register supported configs for specific framework.

Parameters:

fwk_name – the framework name.