Create a kernel-wise operator

Hi,

I’m wondering whether we can use the PyTorch capacity to create a kernel-wise operator or not. By kernel-wise operator, I mean an operator like max pool which applies to a window (kennel size) but instead of getting the max value over that window applies another function over that window. Is there any way to have such an operator in Pytorch?

You could try out your method by creating each window patch via unfold, apply your method, and reshape it to the output shape.
This post gives you an example of this approach.

Note that this approach will most likely be slow, but might be good enough to experiment with your method. If you need a more performance you might want to write a custom extension.

1 Like

Thanks for your reply. I actually wanted to implement 2d fft on a window. I noticed that there exist a fft operator in pytorch but it seems slow on the implementation.

Thanks again for your reply.