neural_compressor.pruner.utils
¶
prune utils.
Module Contents¶
Functions¶
|
Check if the configuration dict is valid for running Pruning object. |
|
Set undefined configurations to default values. |
|
Update parameters. |
|
Process pruning configurations. |
|
Process the yaml configuration file. |
|
Check the validity of keys. |
Process and check configurations. |
|
|
Obtain a config dict object from the config file. |
|
Keep target pruned layers. |
- neural_compressor.pruner.utils.check_config(prune_config)¶
Check if the configuration dict is valid for running Pruning object.
- Parameters:
prune_config – A config dict object that contains Pruning parameters and configurations.
- Returns:
None if everything is correct.
- Raises:
AssertionError. –
- neural_compressor.pruner.utils.reset_none_to_default(obj, key, default)¶
Set undefined configurations to default values.
- Parameters:
obj – A dict{key: value}
key – A string representing the key in obj.
default – When the key is not in obj, add key by the default item in original obj.
- neural_compressor.pruner.utils.update_params(info)¶
Update parameters.
- neural_compressor.pruner.utils.process_weight_config(global_config, local_configs, default_config)¶
Process pruning configurations.
- Parameters:
global_config – A config dict object that contains pruning parameters and configurations.
local_config – A config dict object that contains pruning parameters and configurations.
default_config – A config dict object that contains pruning parameters and configurations.
- Returns:
A config dict object that contains pruning parameters and configurations.
- Return type:
pruners_info
- neural_compressor.pruner.utils.process_yaml_config(global_config, local_configs, default_config)¶
Process the yaml configuration file.
- Parameters:
global_config – A config dict object that contains pruning parameters and configurations.
local_config – A config dict object that contains pruning parameters and configurations.
default_config – A config dict object that contains pruning parameters and configurations.
- Returns:
A config dict object that contains pruning parameters and configurations.
- Return type:
pruners_info
- neural_compressor.pruner.utils.check_key_validity(template_config, user_config)¶
Check the validity of keys.
- Parameters:
template_config – A default config dict object that contains pruning parameters and configurations.
user_config – A user config dict object that contains pruning parameters and configurations.
- neural_compressor.pruner.utils.process_and_check_config(val)¶
Process and check configurations.
- Parameters:
val – A dict that contains the layer-specific pruning configurations.
- neural_compressor.pruner.utils.process_config(config)¶
Obtain a config dict object from the config file.
- Parameters:
config – A string representing the path to the configuration file.
- Returns:
A config dict object.
- neural_compressor.pruner.utils.parse_to_prune(config, model)¶
Keep target pruned layers.
- Parameters:
config – A string representing the path to the configuration file.
model – The model to be pruned.