nncf.common.sparsity.statistics#

Classes#

SparsifiedLayerSummary

Contains information about the sparsified layer.

SparsifiedModelStatistics

Contains statistics of the sparsified model.

MagnitudeSparsityStatistics

Contains statistics of the magnitude sparsity algorithm.

ConstSparsityStatistics

Contains statistics of the const sparsity algorithm.

RBSparsityStatistics

Contains statistics of the RB-sparsity algorithm.

MovementSparsityStatistics

Contains statistics of the movement-sparsity algorithm.

class nncf.common.sparsity.statistics.SparsifiedLayerSummary(name, weight_shape, sparsity_level, weight_percentage)[source]#

Contains information about the sparsified layer.

Parameters:
  • name (str) – Layer’s name.

  • weight_shape (List[int]) – Weight’s shape.

  • sparsity_level (float) – Sparsity level of the sparsified layer.

  • weight_percentage (float) – Proportion of the layer’s weights in the whole model.

class nncf.common.sparsity.statistics.SparsifiedModelStatistics(sparsity_level, sparsity_level_for_layers, sparsified_layers_summary)[source]#

Bases: nncf.api.statistics.Statistics

Contains statistics of the sparsified model.

Parameters:
  • sparsity_level (float) – Sparsity level of the whole model.

  • sparsity_level_for_layers (float) – Sparsity level of all sparsified layers (i.e. layers for which the algorithm was applied).

  • sparsified_layers_summary (List[SparsifiedLayerSummary]) – Detailed summary for the sparsified layers.

to_str()[source]#

Returns a representation of the statistics as a human-readable string.

Return type:

str

class nncf.common.sparsity.statistics.MagnitudeSparsityStatistics(model_statistics, thresholds, target_sparsity_level)[source]#

Bases: nncf.api.statistics.Statistics

Contains statistics of the magnitude sparsity algorithm.

Parameters:
  • model_statistics (SparsifiedModelStatistics) – Statistics of the sparsified model.

  • thresholds (List[LayerThreshold]) – List of the sparsity thresholds.

  • target_sparsity_level (float) – A target level of the sparsity for the algorithm for the current epoch.

to_str()[source]#

Returns a representation of the statistics as a human-readable string.

Return type:

str

class nncf.common.sparsity.statistics.ConstSparsityStatistics(model_statistics)[source]#

Bases: nncf.api.statistics.Statistics

Contains statistics of the const sparsity algorithm.

Parameters:

model_statistics (SparsifiedModelStatistics) – Statistics of the sparsified model.

to_str()[source]#

Returns a representation of the statistics as a human-readable string.

Return type:

str

class nncf.common.sparsity.statistics.RBSparsityStatistics(model_statistics, target_sparsity_level, mean_sparse_prob)[source]#

Bases: nncf.api.statistics.Statistics

Contains statistics of the RB-sparsity algorithm.

Parameters:
  • model_statistics (SparsifiedModelStatistics) – Statistics of the sparsified model.

  • target_sparsity_level (float) – A target level of the sparsity for the algorithm for the current epoch.

  • mean_sparse_prob (float) – The probability that one weight will be zeroed.

to_str()[source]#

Returns a representation of the statistics as a human-readable string.

Return type:

str

class nncf.common.sparsity.statistics.MovementSparsityStatistics(model_statistics, importance_threshold, importance_regularization_factor)[source]#

Bases: nncf.api.statistics.Statistics

Contains statistics of the movement-sparsity algorithm.

Parameters:
  • model_statistics (SparsifiedModelStatistics) – Statistics of the sparsified model.

  • importance_threshold (float) – Importance threshold for sparsity binary mask.

  • importance_regularization_factor (float) – Penalty factor of importance score.

to_str()[source]#

Returns a representation of the statistics as a human-readable string.

Return type:

str