Hi

I have a very specific operation I’d like to implement in PyTorch, it has no trainable parameters but needs to be differentiable. The operation works as follows:

- Take a fixed size window eg. 7x7
- Take the mean of the left half of the window and the mean of the right half of the window (always ignoring the center column)
- Set the center value to the ratio of the left side to the right side ( output(3,3) = MEANleft / MEANright)
- Repeat over the entire image (No padding needed)

I have implemented this forward method using loops but it is really slow. Is there a simple way to do this with Tensor Comprehensions? Or a better way to apply such an operation using existing layers?

Thanks