As @albanD explained, you cannot register a hook on a tensor, as it’s already available.
Based on your previous code snippet I guess you could use an nn.Identity layer, pass x to it after the exp operation and register a hook on this “fake” layer. I don’t think it would be cleaner than storing the tensor as in your last code snippet, but you might prefer this approach.