Hi Dear AlbanD, @albanD
It seems the staticmethod is faster than the old sttyle function (ctx comparing with self).
But what if I need to output some auxiliary output in the forward pass, which does not need to receive its gradient?
In the old style, what I do is to create another instance method which is separate from the forward pass.
A more concrete example:
class F(torch.autograd.Function):
    def __init__(self):
        super(F).__init__()

    def some_func(self, x2):
         //self.x is also needed here
         return z2

    def forward(self, x):
         self.x = x
         z1 = self.some_func(self.x)
         return y
                 
    def backward(self, y.grad):
         return x.grad

y = F()(x)
z2 = F()(x2)
y.backward()

Is there a way that this old styled can be re-rewriten into the new style (using ‘ctx’)?
Thanks a lot!