:py:mod:`neural_compressor.compression.pruner.patterns.base` ============================================================ .. py:module:: neural_compressor.compression.pruner.patterns.base .. autoapi-nested-parse:: Pruning patterns. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: neural_compressor.compression.pruner.patterns.base.BasePattern neural_compressor.compression.pruner.patterns.base.PytorchBasePattern neural_compressor.compression.pruner.patterns.base.KerasBasePattern Functions ~~~~~~~~~ .. autoapisummary:: neural_compressor.compression.pruner.patterns.base.register_pattern .. py:function:: register_pattern(name) Class decorator used to register a Pattern subclass to the registry. Decorator function used before a Pattern subclasses. Make sure that this Pattern class can be registered in PATTERNS. :param name: A string defining the pattern type name to be used in a pruning process. :returns: The class of register. :rtype: cls .. py:class:: BasePattern(config, modules) Pruning Pattern. It defines the basic pruning unit and how this unit will be pruned during pruning, e.g. 4x1, 2:4. :param config: A config dict object that contains the pattern information. :param modules: neural network modules to be pruned with the pattern. .. attribute:: pattern A config dict object that includes information of the pattern. .. attribute:: is_global A bool determining whether the pruning takes global pruning option. Global pruning means that pruning scores by a pruning criterion are evaluated in all layers. Local pruning, by contrast, means that pruning scores by the pruning criterion are evaluated in every layer individually. .. attribute:: keep_mask_layers A dict that includes the layers whose mask will not be updated. .. attribute:: invalid_layers The layers whose shapes don't fit the pattern. .. attribute:: modules neural network modules to be pruned with the pattern. .. attribute:: config A config dict object that contains all the information including the pattern's. .. attribute:: max_sparsity_ratio_per_op A float representing the maximum sparsity that one layer could reach. .. attribute:: min_sparsity_ratio_per_op A float representing the minimum sparsity that one layer could reach. .. attribute:: target_sparsity A float representing the sparsity ratio of the modules after pruning. .. py:class:: PytorchBasePattern(config, modules) Pruning Pattern. It defines the basic pruning unit and how this unit will be pruned during pruning, e.g. 4x1, 2:4. :param config: A config dict object that contains the pattern information. :param modules: neural network modules to be pruned with the pattern. .. attribute:: pattern A config dict object that includes information of the pattern. .. attribute:: is_global A bool determining whether the pruning takes global pruning option. Global pruning means that pruning scores by a pruning criterion are evaluated in all layers. Local pruning, by contrast, means that pruning scores by the pruning criterion are evaluated in every layer individually. .. attribute:: keep_mask_layers A dict that includes the layers whose mask will not be updated. .. attribute:: invalid_layers The layers whose shapes don't fit the pattern. .. attribute:: modules neural network modules to be pruned with the pattern. .. attribute:: config A config dict object that contains all the information including the pattern's. .. attribute:: max_sparsity_ratio_per_op A float representing the maximum sparsity that one layer could reach. .. attribute:: min_sparsity_ratio_per_op A float representing the minimum sparsity that one layer could reach. .. attribute:: target_sparsity A float representing the sparsity ratio of the modules after pruning. .. py:class:: KerasBasePattern(config, modules) Pruning Pattern. It defines the basic pruning unit and how this unit will be pruned during pruning, e.g. 4x1, 2:4. :param config: A config dict object that contains the pattern information. :param modules: neural network modules to be pruned with the pattern. .. attribute:: pattern A config dict object that includes information of the pattern. .. attribute:: is_global A bool determining whether the pruning takes global pruning option. Global pruning means that pruning scores by a pruning criterion are evaluated in all layers. Local pruning, by contrast, means that pruning scores by the pruning criterion are evaluated in every layer individually. .. attribute:: keep_mask_layers A dict that includes the layers whose mask will not be updated. .. attribute:: invalid_layers The layers whose shapes don't fit the pattern. .. attribute:: modules neural network modules to be pruned with the pattern. .. attribute:: config A config dict object that contains all the information including the pattern's. .. attribute:: max_sparsity_ratio_per_op A float representing the maximum sparsity that one layer could reach. .. attribute:: min_sparsity_ratio_per_op A float representing the minimum sparsity that one layer could reach. .. attribute:: target_sparsity A float representing the sparsity ratio of the modules after pruning.