neural_compressor.compression.pruner.pruners
Pruner.
Module Contents
Classes
Pruning Pruner. |
|
Pruning Pruner. |
|
Pruning Pruner. |
|
Pruning Pruner. |
Functions
|
Class decorator to register a Pruner subclass to the registry. |
Get all valid pruner names. |
|
|
Get registered pruner class. |
- neural_compressor.compression.pruner.pruners.register_pruner(name)[source]
Class decorator to register a Pruner subclass to the registry.
Decorator function used before a Pattern subclass. Make sure that the Pruner class decorated by this function can be registered in PRUNERS.
- Parameters:
cls (class) – The subclass of register.
name – A string. Define the pruner type.
- Returns:
The class of register.
- Return type:
cls
- neural_compressor.compression.pruner.pruners.parse_valid_pruner_types()[source]
Get all valid pruner names.
- neural_compressor.compression.pruner.pruners.get_pruner(config, modules)[source]
Get registered pruner class.
Get a Pruner object from PRUNERS.
- Parameters:
modules – A dict {“module_name”: Tensor} that stores the pruning modules’ weights.
config – A config dict object that contains the pruner information.
- Returns:
A Pruner object.
Raises: AssertionError: Cuurently only support pruners that have been registered in PRUNERS.
- class neural_compressor.compression.pruner.pruners.BasePruner(config, modules)[source]
Pruning Pruner.
The class which executes pruning process.
- Parameters:
modules – A dict {“module_name”: Tensor} that stores the pruning modules’ weights.
config – A config dict object that contains the pruner information.
- scores[source]
A dict {“module_name”: Tensor} that stores the score for modules’ weights, which are used to determine what parts to be pruned by a criterion.
- current_sparsity_ratio[source]
A float representing the current model’s sparsity ratio; it is initialized to be zero.
- class neural_compressor.compression.pruner.pruners.BasicPruner(config, modules)[source]
Pruning Pruner.
The class which executes pruning process. 1. Defines pruning functions called at step begin/end, epoch begin/end. 2. Defines the pruning criterion.
- Parameters:
modules – A dict {“module_name”: Tensor} that stores the pruning modules’ weights.
config – A config dict object that contains the pruner information.
- class neural_compressor.compression.pruner.pruners.PatternLockPruner(config, modules)[source]
Pruning Pruner.
A Pruner class derived from BasePruner. In this pruner, original model’s sparsity pattern will be fixed while training. This pruner is useful when a user trains a sparse model without changing its original structure.
- Parameters:
modules – A dict {“module_name”: Tensor} that stores the pruning modules’ weights.
config – A config dict object that contains the pruner information.
- Inherit from parent class Pruner.
- class neural_compressor.compression.pruner.pruners.ProgressivePruner(config, modules)[source]
Pruning Pruner.
A Pruner class derived from BasePruner. In this pruner, mask interpolation will be applied. Mask interpolation is a fine-grained improvement for NxM structured pruning by adding interval
masks between masks of two pruning steps.
- Parameters:
modules – A dict {“module_name”: Tensor} that stores the pruning modules’ weights.
config – A config dict object that contains the pruner information.
- Inherit from parent class Pruner.