Channel Wise Pruning Error

I’m trying to prune a CNN network channel-wise.

When I try on VGG, it works perfectly; however, when I try the exact implementation on mobilenetV2(timm), it throws an error that my input fed and the layer shape isn’t compatible.

RuntimeError: Given groups=32, expected weight to be at least 32 at dimension 0, but got a weight of size [29, 1, 3, 3] instead.

I dug into the issue and was inspecting the shapes layer by layer. The layer that is anomalous is self.conv_dw.weight ({Conv2d} Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), groups=32, bias=False).

I checked the layer weight shape: {Size: 4} torch.Size([29, 1, 3, 3]), while the shape of input being fed is X = {Tensor: (2, 29, 16, 16)}.

As far as I can see, the input and the layers are compatible with conv2d. Am I missing something here?

Attaching the code here: Channel Wise Pruning

The problem was resolved, the Conv groups was causing the trouble. Once I set the pruned number of groups it worked flawlessly.