Dear Sami,
Mentioned link “Custom a new convolution layer in cnn 168” is useful but it is just about forward pass of convolution layer. Backward pass have its own problems. For example, you should manage the dimension of produced gradient in your evaluations.
I suggest you to use Pytorch functions. Since Convolution is equivalent with Unfold + Matrix Multiplication + Fold maybe what ptrblck recommended you would be more useful and simpler.
I mean that whatever you can use ready Pytorch functions and I think most of the time there is a way instead of customizing layers.
If you want to customize a layer, I suggest you to check the open source implementation of multi-layer perceptron and convolution layer and their theories. Also, these two tutorials could help you:
https://pytorch.org/tutorials/advanced/numpy_extensions_tutorial.html 69
https://towardsdatascience.com/only-numpy-understanding-back-propagation-for-transpose-convolution-in-multi-layer-cnn-with-c0a07d191981 58
Of course, what ptrblck sayes is more professional than mine.
Good luck