In my model, the weight of conv is determined by another tensor(let’s call it weight_real) on the fly while running model, the actual parameter to be optimized is weight_real but not the weight itself.
So I create a new module that calls F.conv2d in forward. What I expected is the grad propagates first from the output to the weight, then from the weight to weight_real.
But I met a trouble that, if I set the weight tensor as a parameter, then the weight will be a leaf node, weight_real can’t get any grad, if I set the weight tensor as a normal tensor, the weight tensor itself can’t get any grad. It seems that only if weight is a parameter but not a normal tensor then its grad will be calculated.
Is there any way to solve this problem?  Thanks in advance!