Did you type cast both the inputs to the nn.Linear() module?

  
      github.com
  
  
    promach/pytorch-pruning/blob/master/prune.py#L96-L97 11

torch.nn.Linear(old_linear_layer.in_features - params_per_input_channel, 
    old_linear_layer.out_features)