pytorch/test/cpp
Jeffrey Wan e71b526e7e Add inference mode python bindings and tests (#58045)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/56608

 - Adds binding to the `c10::InferenceMode` RAII class in `torch._C._autograd.InferenceMode` through pybind. Also binds the `torch.is_inference_mode` function.
 - Adds context manager `torch.inference_mode` to manage an instance of `c10::InferenceMode` (global).  Implemented in `torch.autograd.grad_mode.py` to reuse the `_DecoratorContextManager` class.
 - Adds some tests based on those linked in the issue + several more for just the context manager

Issues/todos (not necessarily for this PR):
- Improve short inference mode description
- Small example
- Improved testing since there is no direct way of checking TLS/dispatch keys
-

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

Reviewed By: agolynski

Differential Revision: D28390595

Pulled By: soulitzer

fbshipit-source-id: ae98fa036c6a2cf7f56e0fd4c352ff804904752c
2021-05-13 08:55:35 -07:00
..
api Add inference mode python bindings and tests (#58045) 2021-05-13 08:55:35 -07:00
common
dist_autograd Fix distributed autograd gradients synchronization (#57792) 2021-05-09 17:32:59 -07:00
jit Striding for lists Part 2 (#49352) 2021-05-13 00:16:02 -07:00
lite_interpreter_runtime Revert D27958477: [PyTorch][Edge] Add v4 and v5 models and remove unused model 2021-04-23 14:42:01 -07:00
rpc Use RPC context streams to cover serde ops (#57926) 2021-05-11 07:07:51 -07:00
tensorexpr [TensorExpr] Implement 'call_raw' in IREval. (#57882) 2021-05-12 14:08:18 -07:00
__init__.py