Sorry, I typed something wrong. HadamardProd does inherit from torch.autograd.Function in my original code.   I don’t know whether leaving out the backward function would work, I 'll try it. Thanks for your suggestions.