Actually, I believe that it is the abuse of .data which blocked the gradients. .data is deprecated, you should use something like .detach() instead. .data will return the value in a tensor without the gradients and directly setting .data will not change the gradients. In this case, you  should create another temporary variable, like:
tempVar = torch.where(self.w > 0, (self.w * self.myParam), self.w)
return F.conv2d(input, tempVar)