neural_compressor.compression.pruner.patterns.nxm

NxM patterns.

Module Contents

Classes

PytorchPatternNxM

Pruning Pattern.

KerasPatternNxM

Pruning Pattern.

class neural_compressor.compression.pruner.patterns.nxm.PytorchPatternNxM(config, modules)[source]

Pruning Pattern.

A Pattern class derived from BasePattern. In this pattern, the weights in a NxM block will be pruned or kept during one pruning step.

Parameters:

config – A config dict object that contains the pattern information.

block_size[source]

A list of two integers representing the height and width of the block.

Please note that the vertical direction of a Linear layer's weight refers to the output channel.

because PyTorch’s tensor matmul has a hidden transpose operation.

class neural_compressor.compression.pruner.patterns.nxm.KerasPatternNxM(config, modules)[source]

Pruning Pattern.

A Pattern class derived from BasePattern. In this pattern, the weights in a NxM block will be pruned or kept during one pruning step.

Parameters:

config – A config dict object that contains the pattern information.

block_size[source]

A list of two integers representing the height and width of the block.

Please note that the vertical direction of a Linear layer's weight refers to the output channel.

because PyTorch’s tensor matmul has a hidden transpose operation.