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 7 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.