Compression Schemes¶
Composition¶
-
class
condensa.schemes.
Compose
(schemes)¶ Composes two or more schemes together.
-
__init__
(schemes)¶ Creates a Compose instance.
- Parameters
schemes (list) – List of schemes to compose.
-
delta
(module)¶ Applies de-compression scheme to module.
- Parameters
module (torch.nn.Module) – PyTorch module.
-
pi
(module)¶ Applies compression scheme to module.
- Parameters
module (torch.nn.Module) – PyTorch module.
-
Unstructured Pruning¶
-
class
condensa.schemes.
Prune
(density)¶ Prunes network to given density.
-
__init__
(density)¶ Creates a Prune instance.
- Parameters
density (float) – Target density.
-
delta
(module)¶ Applies de-compression scheme to module.
- Parameters
module (torch.nn.Module) – PyTorch module.
-
pi
(module)¶ Applies compression scheme to module.
- Parameters
module (torch.nn.Module) – PyTorch module.
-
threshold
(module)¶ Computes magnitude threshold.
- Parameters
module (torch.nn.Module) – PyTorch module.
-
Quantization¶
-
class
condensa.schemes.
Quantize
(dtype=<condensa.dtypes.DType object>)¶ Quantizes network to given data-type.
-
__init__
(dtype=<condensa.dtypes.DType object>)¶ Creates Quantize class instance.
- Parameters
dtype – Target data type (default: float16).
-
delta
(module)¶ Applies de-compression scheme to module.
- Parameters
module (torch.nn.Module) – PyTorch module.
-
pi
(module)¶ Applies compression scheme to module.
- Parameters
module (torch.nn.Module) – PyTorch module.
-
Neuron Pruning¶
-
class
condensa.schemes.
NeuronPrune
(density, align=None, criteria=<function l2norm>, prune_bias=True)¶ Prunes neurons from fully-connected layers.
-
__init__
(density, align=None, criteria=<function l2norm>, prune_bias=True)¶ Creates an instance of NeuronPrune.
- Parameters
density (float) – Target density.
align (int) – Tensor alignment in compressed model.
criteria (condensa.functional) – Neuron aggregation criteria (default: l2norm).
prune_bias (bool) – Whether to prune corresponding biases (default: True).
-
delta
(module)¶ Applies de-compression scheme to module.
- Parameters
module (torch.nn.Module) – PyTorch module.
-
pi
(module)¶ Applies compression scheme to module.
- Parameters
module (torch.nn.Module) – PyTorch module.
-
threshold
(module)¶ Computes magnitude threshold.
- Parameters
module (torch.nn.Module) – PyTorch module.
-
Filter Pruning¶
-
class
condensa.schemes.
FilterPrune
(density, align=None, criteria=<function l2norm>, prune_bias=True)¶ Prunes filters from convolutional layers.
-
__init__
(density, align=None, criteria=<function l2norm>, prune_bias=True)¶ Creates an instance of FilterPrune.
- Parameters
density (float) – Target density.
align (int) – Tensor alignment in compressed model.
criteria (condensa.functional) – Filter aggregation criteria (default: l2norm).
prune_bias (bool) – Whether to prune corresponding biases (default: True).
-
delta
(module)¶ Applies de-compression scheme to module.
- Parameters
module (torch.nn.Module) – PyTorch module.
-
pi
(module)¶ Applies compression scheme to module.
- Parameters
module (torch.nn.Module) – PyTorch module.
-
threshold
(module)¶ Computes magnitude threshold.
- Parameters
module (torch.nn.Module) – PyTorch module.
-
Structured Pruning¶
-
class
condensa.schemes.
StructurePrune
(density, align=None, criteria=<function l2norm>, prune_bias=True)¶ Combines neuron and filter pruning using a single threshold value.
-
__init__
(density, align=None, criteria=<function l2norm>, prune_bias=True)¶ Creates an instance of StructurePrune.
- Parameters
density (float) – Target density.
align (int) – Tensor alignment in compressed model.
criteria (condensa.functional) – Structure aggregation criteria (default: l2norm).
prune_bias (bool) – Whether to prune corresponding biases (default: True).
-
delta
(module)¶ Applies de-compression scheme to module.
- Parameters
module (torch.nn.Module) – PyTorch module.
-
pi
(module)¶ Applies compression scheme to module.
- Parameters
module (torch.nn.Module) – PyTorch module.
-
threshold
(module)¶ Computes magnitude threshold.
- Parameters
module (torch.nn.Module) – PyTorch module.
-
Block Pruning¶
-
class
condensa.schemes.
BlockPrune
(density, block_size, criteria=<function l2norm>)¶ Prunes blocks in Linear layers.
-
__init__
(density, block_size, criteria=<function l2norm>)¶ Creates an instance of BlockPrune.
- Parameters
density (float) – Target density.
block_size (Tuple) – Target block size.
criteria (condensa.functional) – Structure aggregation criteria (default: l2norm).
-
delta
(module)¶ Applies de-compression scheme to module.
- Parameters
module (torch.nn.Module) – PyTorch module.
-
pi
(module)¶ Applies compression scheme to module.
- Parameters
module (torch.nn.Module) – PyTorch module.
-
threshold
(module)¶ Computes magnitude threshold.
- Parameters
module (torch.nn.Module) – PyTorch module.
-