-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Add a private API that lists overridable functions #33182
Description
🚀 Feature
Add a way for library authors who depend on pytorch to get a list of all functions that they would need to implement to fully wrap the API surface that is overridable via __torch_function__.
Motivation
See e.g. #27064 (comment).
Pitch
Currently it's not straightforward for authors of types that implement __torch_function__ to test that they fully cover the API that is overridable via __torch_function__. It's important that they are able to wrap as much of the API as possible because once you have written a type that implements __torch_function__ users of that type will see a TypeError if the __torch_function__ implementation returns NotImplemented for unwrapped functions.
It would be nice if there were some private API that gave developers access to the functions that are overridable. It might also be nice to include the function signatures in an easily introspectable format as that makes it easier to write tests for the overrides.
Alternatives
It might also be sufficient to just have a list of functions in the documentation.