Make saved tensors default hooks thread local (#62909)
authorVictor Quach <quach@fb.com>
Fri, 13 Aug 2021 14:47:12 +0000 (07:47 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Fri, 13 Aug 2021 14:49:20 +0000 (07:49 -0700)
commit5abeac3ef70a5ff3035f5cd11a217b5d15ebcd49
tree9fbaf96aa228b6cdc09e7c2cf0366c5d4e5e2222
parentcb23976f9f304a6db62b612c83aae371a077031f
Make saved tensors default hooks thread local (#62909)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/62909

This PR makes saved tensors default hooks thread local.
This allows using default hooks in a multithreaded context.

Test Plan: Imported from OSS

Reviewed By: albanD

Differential Revision: D30165416

Pulled By: Varal7

fbshipit-source-id: 10a7d580661d3d94bdaf398c4e076b7bea11c16b
aten/src/ATen/SavedTensorHooks.cpp [new file with mode: 0644]
aten/src/ATen/SavedTensorHooks.h [new file with mode: 0644]
aten/src/ATen/ThreadLocalState.cpp
aten/src/ATen/ThreadLocalState.h
test/test_autograd.py
tools/build_variables.bzl
torch/csrc/autograd/python_saved_variable_hooks.cpp
torch/csrc/autograd/python_saved_variable_hooks.h