Silently disable default saved tensor hooks during tracing (#123196)
Summary:
FIXES #113263. Same idea as in https://github.com/pytorch/pytorch/pull/113417, but we need a more intrusive C API to silently nop default saved tensor hooks, in order to support user-code that use torch.autograd.disable_saved_tensors_hooks (see test_unpack_hooks_can_be_disabled). We mock the output of get_hooks while leaving push/pop untouched.
For compiled autograd, we're firing pack hooks once and unpack hooks twice right now, I'll look into this separately from this issue.
X-link: https://github.com/pytorch/pytorch/pull/123196
Approved by: https://github.com/soulitzer
Reviewed By: izaitsevfb
Differential Revision: D58628125
Pulled By: xmfan
fbshipit-source-id: 399cba07d50610ba52da55951f7b2200eb9c217f