No worries, that happens to me a lot



 albanD:

Sorry I missed your conv2d as a static function, my bad.



I am working on Colab, which uses the v1.4.0. I put that exception to get the error in case the update the current stable version.



 albanD:

You nn.Module does not work for me and through the not implemented error from _conv_forward



Oh I see. Thanks. On my original code, the one I first experimented this issue, I don’t call forward() myself. I use the class from standard torch examples of a neural network (Lenet) with a few changes.



 albanD:

You should never call the .forward() of the nn.Module directly. You should use the __call__ on it as result = layer(image) .



I suspected. Thanks for the clarification. I did both cases just to be safe, as a quick test.



 albanD:

You don’t need to wrap things in Variables anymore. You can just use regular Tensors: image = torch.from_numpy(image).requires_grad_() .



Wow. I really looked for inplace operations. At first, I thought output += bias.view()
could be inplace. But, for some reason, I sticked with "Well, that should be the same thing as output = output+bias". I totally should had tried that!



 albanD:

“”"
…/torch/csrc/autograd/variable.cpp:421: UserWarning: Output 0 of _Conv2dCustomBackward is a view and its base or another view of its base has been modified inplace. This view was created inside a custom Function (or because an input was returned as-is) and the autograd logic to handle view+inplace would override the custom backward associated with the custom Function, leading to incorrect gradients. This behavior is deprecated and will be forbidden starting version 1.6. You can remove this warning by cloning the output of the custom Function.
“”"
As it states, the fact that your custom Function returns a view and that you modify it inplace in when adding the bias break some internal autograd assumptions.
You should either change _conv2d to return output.clone() to avoid returning a view. Or change your bias update to output = output + bias.view(-1, 1, 1) to avoid the inplace operations.



Thank you so much! You saved my week! I really appreciate this community!

Just one more question, from the Extending Pytorch page:
Shouldn’t the inplace operation be an issue only for the input parameters on the forward pass?



 mark_dirty()  3 must be used to mark any input that is modified inplace by the forward function.