Skip to content

Add a private API that lists overridable functions #33182

@ngoldbaum

Description

@ngoldbaum

🚀 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.

Metadata

Metadata

Assignees

Labels

enhancementNot as big of a feature, but technically not a bug. Should be easy to fixmodule: testsIssues related to tests (not the torch.testing module)triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions