Pruner
def Pruner(
model, pruning_ratio, # Filters to remove, a fraction in [0, 1] (0.4 = 40%), or a per-layer dict
context, # 'local' (per-layer) or 'global' (across the whole model)
criteria, # How to select filters to prune, from `fasterai.core.criteria`
schedule:function=linear_scheduler, # How the ratio progresses over the pruning steps
ignored_layers:NoneType=None, # Layers to leave untouched; None = output Linear and attention qkv
example_inputs:torch.Tensor=tensor([[[[ 0.7898, 0.7097, 0.5723, ..., 0.1163, -1.1751, 0.2450],
[-2.9112, 0.8402, 0.9179, ..., 0.0063, 1.1288, -0.5749],
[-0.4368, -0.2378, 0.2966, ..., 0.5499, -0.3741, -1.0524],
...,
[ 0.4741, 1.6081, -0.7943, ..., 0.6774, -2.6864, 1.5412],
[ 1.0689, 1.9963, -1.0343, ..., 0.1956, 0.1118, 1.8849],
[-1.4006, 0.5151, 1.2845, ..., 1.0530, 0.6049, 2.1309]],
[[ 0.2921, -0.6453, -0.3414, ..., 1.2958, 1.1668, -0.2857],
[-0.5511, 0.5821, -0.7695, ..., 1.2242, -0.8694, 0.8368],
[ 0.4427, 0.8401, 1.6323, ..., 0.5839, -0.6443, -1.8225],
...,
[-0.3913, -0.4440, -1.7214, ..., 0.4686, -0.2093, -0.5390],
[-0.5736, -1.0965, 0.8492, ..., -0.3786, -1.0599, 0.2434],
[ 1.1565, -0.1106, 0.1925, ..., 0.2077, 0.4050, 1.3106]],
[[-0.3615, -2.0190, -0.0304, ..., -0.1565, -1.1915, 1.9885],
[ 0.9545, -0.4652, -0.2961, ..., 0.1086, -0.4314, -0.0212],
[ 1.4138, 0.2314, 0.0234, ..., -1.3838, 0.6656, 0.0602],
...,
[ 0.3877, 1.4464, -0.9274, ..., 1.2363, 0.2762, 1.5912],
[-1.9060, 0.8510, -0.7314, ..., 0.4636, 1.8307, 0.4928],
[ 1.7752, -0.1500, 0.3221, ..., -0.0986, 0.1571, 1.0670]]]]), # Input used to trace layer dependencies
*args, **kwargs
):Structured pruning for neural networks using torch_pruning