Hi,
I would like to collapse a serie of 2d convolutions to a single conv operation.
Basically I’d like to make the pytorch convolution associative.
For example if I have something like
y = F.conv2d(F.conv2d(a1,k1),k0)
I’d like to write it this way: y = F.conv2d(a1,K) (where K depends on k1 and k2).
If my calculus are not wrong, this should work:
a1 = torch.randn(1,100,256,256)
k1 = torch.randn(25,100,5,5)
k0 = torch.rand(1,25,5,5)

a0 = F.conv2d(a1,k1)
y = F.conv2d(a0,k0)

K = F.conv2d(k1.transpose(0,1),k0,padding=4).transpose(0,1)
y2 = F.conv2d(a1,K)

But it doesn’t work.
Does anyone know what I am forgetting ? Thanks