:py:mod:`neural_compressor.experimental.pytorch_pruner.patterns` ================================================================ .. py:module:: neural_compressor.experimental.pytorch_pruner.patterns .. autoapi-nested-parse:: Pattern module. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: neural_compressor.experimental.pytorch_pruner.patterns.Pattern neural_compressor.experimental.pytorch_pruner.patterns.PatternNxM neural_compressor.experimental.pytorch_pruner.patterns.PatternNInM Functions ~~~~~~~~~ .. autoapisummary:: neural_compressor.experimental.pytorch_pruner.patterns.register_pattern neural_compressor.experimental.pytorch_pruner.patterns.get_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 cls: The class of register. :type cls: class :param name: A string. Define the pattern type which will be included in a pruning process. :returns: The class of register. :rtype: cls .. py:function:: get_pattern(config) Get registered pattern class. Get a Pattern object from PATTERNS. :param config: A config dict object. Contains the pattern information. :returns: A Pattern object. :raises AssertionError: Currently only support patterns which have been registered in PATTERNS. .. py:class:: Pattern(config) Pruning Pattern. Every Pruner object will contain a Pattern object. It defines the basic pruning unit and how this unit will be pruned during pruning. :param config: A config dict object. Contains the pattern information. .. attribute:: pattern A config dict object. The pattern related part in args config. .. attribute:: is_global A bool. Whether the pruning take global pruning option. Global pruning means that all pruning layers are gathered to calculate pruning criteria. Local pruning, on the contrast, means that pruning layers are to calculate criteria individually. .. py:class:: PatternNxM(config) Pruning Pattern. A Pattern class derived from Pattern. In this pattern, the weights in a NxM block will be pruned or kept during one pruning step. :param config: A config dict object. Contains the pattern information. .. attribute:: block_size A list of two Integers. The height and width of the block. Please be aware that the vertical direction of a Linear layer's weight in PyTorch refer to output channel. Because PyTorch's tensor matmul has a hidden transpose operation. .. py:class:: PatternNInM(config) Pruning Pattern. A Pattern class derived from Pattern. In this pattern, N out of every M continuous weights will be pruned. For more info of this pattern, please refer to https://github.com/intel/neural-compressor/blob/master/docs/pruning.md :param config: A config dict object. Contains the pattern information. .. attribute:: N The number of elements to be prune in a weight sequence. .. attribute:: M The size of the weight sequence.