nncf.torch.sparsity.magnitude.algo
#
Classes#
Controller for the magnitude sparsity algorithm in PT. |
- class nncf.torch.sparsity.magnitude.algo.MagnitudeSparsityController(target_model, sparsified_module_info, config)[source]#
Bases:
nncf.torch.sparsity.base_algo.BaseSparsityAlgoController
Controller for the magnitude sparsity algorithm in PT.
- Parameters:
target_model (nncf.torch.nncf_network.NNCFNetwork) –
sparsified_module_info (List[nncf.torch.sparsity.base_algo.SparseModuleInfo]) –
config (nncf.NNCFConfig) –
- property compression_rate[source]#
Returns a float compression rate value ranging from 0 to 1 (e.g. the sparsity level, or the ratio of filters pruned).
- statistics(quickly_collected_only=False)[source]#
Returns a Statistics class instance that contains compression algorithm statistics.
- Parameters:
quickly_collected_only (bool) – Enables collection of the statistics that don’t take too much time to compute. Can be helpful for the case when need to keep track of statistics on each training batch/step/iteration.
- Return type:
- freeze(freeze=True)[source]#
Freezes all sparsity masks. Sparsity masks will not be trained after calling this method.
- Parameters:
freeze (bool) –
- set_sparsity_level(sparsity_level, target_sparsified_module_info=None, run_batchnorm_adaptation=False)[source]#
Sets the sparsity level that should be applied to the model’s weights.
- Parameters:
sparsity_level – Sparsity level that should be applied to the model’s weights.
target_sparsified_module_info (nncf.torch.sparsity.base_algo.SparseModuleInfo) –
run_batchnorm_adaptation (bool) –