pytorch/docs/source
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
..
_static Improve documentation around builtin functions (#30347) 2019-12-04 13:50:40 -08:00
_templates Generate sphinx docs with secure content. (#18508) 2019-03-27 11:01:48 -07:00
community Fix broken links in governance.rst 2020-02-04 14:26:09 -08:00
notes Add API for listing functions overridable by __torch_function__ (#33791) 2020-03-03 12:40:34 -08:00
org/pytorch Revert D19320493: Javadoc changes 2020-01-09 14:23:30 -08:00
scripts Add torch.nn.GELU for GELU activation (#28944) 2019-11-03 21:55:05 -08:00
__config__.rst Allow a non-OpenMP based build (#19749) 2019-05-06 19:34:48 -07:00
amp.rst [WIP] Reanimate gradient scaling API with original scale update heuristic (#33366) 2020-02-25 19:00:34 -08:00
autograd.rst Added docs for context method mixins. Fixes issue #27365 (#28643) 2019-10-28 08:31:35 -07:00
bottleneck.rst
checkpoint.rst Stashing checkpointing RNG states based on devices of arg tensors (#14518) 2018-12-11 09:48:45 -08:00
conf.py Revert D19320493: Javadoc changes 2020-01-09 14:23:30 -08:00
cpp_extension.rst
cuda_deterministic_backward.rst Typo correction in cuda_deterministic_backward.rst (#25011) 2019-08-22 21:19:39 -07:00
cuda_deterministic.rst Amend nondeterminism notes (#12217) 2018-10-16 23:59:26 -07:00
cuda.rst Fix most documentation warnings (#27782) 2019-10-13 10:34:01 -07:00
cudnn_deterministic.rst Amend nondeterminism notes (#12217) 2018-10-16 23:59:26 -07:00
cudnn_persistent_rnn.rst don't copy weight gradients in rnn (#12600) 2018-10-12 13:34:10 -07:00
data.rst Fix typo in data.rst docs 2019-12-18 09:52:10 -08:00
distributed.rst Fix typos (#30606) 2019-12-02 20:17:42 -08:00
distributions.rst Feature/vonmises upstream (#33418) 2020-02-26 08:19:12 -08:00
dlpack.rst
hub.rst Fix typos, via a Levenshtein-type corrector (#31523) 2020-01-17 16:03:19 -08:00
index.rst Add list of view ops to public doc. (#32560) 2020-02-28 15:05:55 -08:00
jit_builtin_functions.rst Fix builtin function reference (#24056) 2019-08-09 15:58:15 -07:00
jit_language_reference.rst [docs] add experimental warning to TorchScript classes in language reference (#33697) 2020-02-24 14:01:19 -08:00
jit_python_reference.rst Add Python language reference docs (#30686) 2019-12-26 13:21:36 -08:00
jit_unsupported.rst Collapse _like overloads into a single overload. (#33705) 2020-03-01 19:40:22 -08:00
jit.rst Fix typos, via a Levenshtein-type corrector (#31523) 2020-01-17 16:03:19 -08:00
math-quantizer-equation.png adding quantization.rst file for quantization feature (#27559) 2019-10-09 16:45:09 -07:00
model_zoo.rst add/move a few apis in torch.hub (#18758) 2019-04-10 23:10:39 -07:00
multiprocessing.rst Bag of documentation fixes; fix more sphinx warnings (#27850) 2019-10-15 07:31:14 -07:00
name_inference.rst Fix typos (#30606) 2019-12-02 20:17:42 -08:00
named_tensor.rst Bag of documentation fixes; fix more sphinx warnings (#27850) 2019-10-15 07:31:14 -07:00
nn.functional.rst Breaks up NN module in docs so it loads faster. 2019-06-11 09:38:41 -07:00
nn.init.rst Bag of documentation fixes; fix more sphinx warnings (#27850) 2019-10-15 07:31:14 -07:00
nn.rst Pruning Functionality (#24076) 2019-11-08 19:38:00 -08:00
onnx.rst [jit] do the code reorg (#33851) 2020-02-27 13:02:51 -08:00
optim.rst Fix capitalization inconsistency in optim.rst 2019-12-04 08:17:03 -08:00
packages.rst Revert D19320493: Javadoc changes 2020-01-09 14:23:30 -08:00
quantization.rst Updates to quantization documentation (#30288) 2019-11-23 09:29:30 -08:00
random.rst Fix most documentation warnings (#27782) 2019-10-13 10:34:01 -07:00
rpc.rst Explain RPC behavior when using Tensor as arg or return value 2020-01-09 16:42:24 -08:00
sparse.rst Bag of documentation fixes; fix more sphinx warnings (#27850) 2019-10-15 07:31:14 -07:00
storage.rst
tensor_attributes.rst Expose a torch.result_type and simplify tensor iterator 2019-09-25 06:52:23 -07:00
tensor_view.rst Add list of view ops to public doc. (#32560) 2020-02-28 15:05:55 -08:00
tensorboard.rst Add method add_hparams to API doc (#27344) 2019-10-03 17:07:45 -07:00
tensors.rst Add list of view ops to public doc. (#32560) 2020-02-28 15:05:55 -08:00
torch.rst [doc] Add grad context manager doc to toplevel torch module. (#33877) 2020-03-02 06:32:36 -08:00
type_info.rst Allow converting char tensor to numpy; add [fi]info.min (#15046) 2018-12-24 09:11:24 -08:00