pytorch/docs/source/notes
Nathan Goldbaum ad2825a2c9 Add API for listing functions overridable by __torch_function__ (#33791)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/33182

This adds private API functions that developers of types that implement `__torch_function__` can use to ensure full coverage of the subset of the PyTorch API that can be overrided.

I've refactored some of the code in the tests into a new `torch._overrides.get_overridable_functions` function. I've also changed `TENSOR_LIKE_TORCH_OVERRIDES` into `torch._overrides.get_testing_overrides` and `IGNORED_TORCH_FUNCTIONS` into `torch._overrides.get_ignored_functions`. Making these two static global variables in the tests into functions should allow rewriting their implementation to construct their return values instead of just statically defining the return value as is done here. Currently that is blocked on not being able to inspect function signatures of compiled kernels in PyTorch (see https://github.com/pytorch/pytorch/issues/28233). See the docs I've added for usage examples of these new functions. I also refactored the existing override tests to make use of these new functions, which should be a good forcing function to make sure they're kept up-to-date.

Finally, while working on this I discovered that `TestTorchFunctionOverrides.test_mean` and `TestTorchFunctionOverrides.test_mm` weren't ever being run because they were getting clobbered by the other dynamically generated override tests. I fixed that by renaming the tests and then fixing the actual test code. I've verified that all the subclassing semantics is correct and that the updated test answers are correct. I'm happy to put the fixes to the existing tests in as a separate pull request if that would be easier to review.

ping cpuhrsch since the feature request originally came from them.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33791

Differential Revision: D20195053

Pulled By: cpuhrsch

fbshipit-source-id: 1585f4e405f5223932b410eae03a288dc8eb627e
2020-03-03 12:40:34 -08:00
..
amp_examples.rst [WIP] Reanimate gradient scaling API with original scale update heuristic (#33366) 2020-02-25 19:00:34 -08:00
autograd.rst Update distributed autograd design doc with appropriate links. (#29927) 2019-11-15 21:10:53 -08:00
broadcasting.rst [docs] Update broadcasting and cuda semantics notes (#6904) 2018-04-24 13:41:24 -04:00
cpu_threading_runtimes.svg Update CPU threading doc (#33083) 2020-02-11 14:13:51 -08:00
cpu_threading_torchscript_inference.rst Update CPU threading doc (#33083) 2020-02-11 14:13:51 -08:00
cpu_threading_torchscript_inference.svg Threading and CPU Inference note 2019-07-29 15:45:49 -07:00
cuda.rst Comprehensive-ish instrumentation for CUDA memory allocator (#27361) 2019-10-08 15:42:48 -07:00
ddp.rst Adding DDP Design Note 2020-01-15 14:10:45 -08:00
distributed_autograd.rst [Dist Autograd] Functional API for Dist Autograd and Dist Optimizer (#33711) 2020-02-26 19:08:28 -08:00
extending.rst Add API for listing functions overridable by __torch_function__ (#33791) 2020-03-03 12:40:34 -08:00
faq.rst Use "length of the RNN input" instead of "length of the RNN" 2019-05-24 09:03:50 -07:00
large_scale_deployments.rst Thread local debug info 2019-08-12 14:53:57 -07:00
multiprocessing.rst Add IterableDataset (#19228) 2019-06-20 20:12:44 -07:00
randomness.rst Update randomness.rst (#21337) 2019-06-04 07:38:00 -07:00
rref.rst Fix RRef design doc warning (#30240) 2019-11-21 16:22:39 -08:00
serialization.rst code syntax error in document (serialization.rst) (#937) 2017-03-06 10:06:04 -05:00
windows.rst Update MKL to 2020.0.166 for Windows (#33690) 2020-02-24 22:43:34 -08:00