Why is the input of hook function a tuple?

I have implemented a forward hook according to what is explained here.

When I apply the hook to an nn.Linear module, I see that the input in the hook function is a tuple of length one, i.e. (tensor, ), while the output is a tensor. Is there a reason why input is a tuple but the output is not?

4 Likes

I am asking myself the same question and was wondering if you had found an answer.

By way of example, I also started from the link you paste, but for a minimal working example I think the official documentation is very relevant.