Solved by albanD in post #2 
              
              
                Hi, 
Please find below code that does it with 2 convs. 
I did not do timings as they might depend on if you use a GPU or not. But that should be significantly faster, especially during the backward pass. 

import torch
from torch.nn import functional as F

device = torch.device("cpu")

# Original co…