I want to make some changes in save_hooks based on which function is running. In one of the discussions on this forum How to have different saved_tensor_hooks for different functions - autograd - PyTorch Forums, a solution where we have to use TorchFunctionMode to get current function is suggesgted. However, this support was not available in pytorch 1.10 . Is there a equivalent way for older pytorch versions to identify which function is running when save hooks are called ?
Writing a torch function subclass would do something similar Extending PyTorch — PyTorch 2.0 documentation, the trickiness though is that you’ll have to make sure that all the tensors you pass in are of that subclass.
Just out of curiosity, why aren’t you able to upgrade to a later version?