pytorch/test/custom_operator
albanD 45c5bac870 [WIP] Fix cpp grad accessor API (#40887)
Summary:
Update the API to access grad in cpp to avoid unexpected thread safety issues.
In particular, with the current API, a check like `t.grad().defined()` is not thread safe.

- This introduces `t.mutable_grad()` that should be used when getting a mutable version of the saved gradient. This function is **not** thread safe.
- The `Tensor& grad()` API is now removed. We could not do a deprecation cycle as most of our call side use non-const Tensors that use the non-const overload. This would lead to most calls hitting the warning. This would be too verbose for all the users.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/40887

Reviewed By: ezyang

Differential Revision: D22343932

Pulled By: albanD

fbshipit-source-id: d5eb909bb743bc20caaf2098196e18ca4110c5d2
2020-07-16 09:11:12 -07:00
..
CMakeLists.txt Separate torchbind from Python (#30242) 2019-12-21 22:52:40 -08:00
model.py Allow building libraries with setuptools that dont have abi suffix (#14130) 2018-11-27 17:35:53 -08:00
op.cpp Support c10::optional<Tensor> in custom C++ autograd function. (#37700) 2020-05-06 01:59:51 -07:00
op.h Test cases for custom ops with autograd (#31003) 2019-12-15 22:37:24 -08:00
test_custom_classes.py Remove python-2 or python<3.5 checks from unit tests (#37252) 2020-04-24 17:42:04 -07:00
test_custom_ops.cpp [WIP] Fix cpp grad accessor API (#40887) 2020-07-16 09:11:12 -07:00
test_custom_ops.py Support c10::optional<Tensor> in custom C++ autograd function. (#37700) 2020-05-06 01:59:51 -07:00