Your Tensor self.w is defined once during the init and then re-used for every forward in the forward method.
So if you add a hook to that Tensor, it will be taken into account at every forward as the Tensor is re-used at every forward.
In your code above, if you register the hook on out you won’t see this behavior anymore because out is a new Tensor at every forward. The behavior you observe here happens because self.w is the same Tensor that is re-used at every forward.