Thx aldanD, @albanD
def propagate(self, kernels,b,c,h,w):
prop_f = torch.empty([b,c,h,w], device='cuda', requires_grad = False) # size [1, 256, 24, 24]
for bb in range(b): #normally b==1, ignore this for loop
for hh in range(h): #24
for ww in range(w): #24
product = self.old_f[ bb,:,hh+p, ww+q ] * kernels[ bb, hh*w+ww, p, q ] # size [1, 256, 1, 1]
prop_f[bb,:, hh, ww] = product # move product into the right pos of prop_f to store
return prop_f
You see, my purpose here is that: the product is of size [ 1, 256, 1 ,1 ], and prop_f is of size [ 1, 256, 24, 24],
so I am going to store every tmp product in the right place of prop_f. So totally I am like processing a sliding window ‘convolution’ fashion. Not as you said,My purpose is not to get the grad of either of them, but to get the silding ‘convolution’ result.
So, intuitively I have to create a container to store all those tmp product in right [hh , ww] position, so that the ‘convolution’ result could be saved and returned. And , I choose torch.empty to do this
Finally, My question is that as you can see , at the beginning the prop_f has no grad, since it’s leaf when created. But after this whole ‘convolution’ above, does it has grad now?, since all its elements are obtained from graph node calculations, such as the calculation between computation graph node self.old_f and kernels
Thx for reading this whole