Thank you. I really hope there is such a way.
I have two inputs, x1 and x2. Let’s consider a simple linear layer. The gradient is originally calculated like :
def backward(self, grad_output) : 
    input, weight = self.saved_tensors
    grad_input = grad_output.mm(weight)
    grad_weight = grad_output.t().mm(input)
    return grad_input,  grad_weight

I want to do something like :
def backward(self, grad_output) : 
    input1, weight = self.saved_tensors
    input2, weight = self.saved_tensors2
    grad_input = grad_output.mm(weight1)
    grad_weight = grad_output.t().mm(input1+input2)
    return grad_input,  grad_weight

I can’t just forward with x1+x2, since It changes nonlinear activations like ReLU, MaxPool, etc. Furthermore, grad_output should be calculated with x1, not with x1+x2. This is really unusual situation, and I found that even deceiving pytorch is not simple. I’m totally blocked  and would be really happy with any help.
Thank you.