Skip to content

Commit bf72312

Browse files
authored
Fix documentation to point to torch.overrides instead of _overrides. (#47843)
Summary: Fixes #47697 Pull Request resolved: #47842 Reviewed By: smessmer Differential Revision: D24951750 Pulled By: ezyang fbshipit-source-id: df62ec2e52f1c561c864a50bac4abf4a55e4f8e6 (cherry picked from commit 3a2aad9) Signed-off-by: Eli Uriegas <eliuriegas@fb.com>
1 parent 4dc1753 commit bf72312

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

docs/source/notes/extending.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -605,13 +605,13 @@ provides a developer-facing API for ensuring full support for
605605
changes without warning in the future.
606606

607607
First, to get a listing of all overridable functions, use
608-
``torch._overrides.get_overridable_functions``. This returns a dictionary whose
608+
``torch.overrides.get_overridable_functions``. This returns a dictionary whose
609609
keys are namespaces in the ``PyTorch`` Python API and whose values are a list of
610610
functions in that namespace that can be overriden. For example, let's print the
611611
names of the first 5 functions in ``torch.nn.functional`` that can be
612612
overriden::
613613

614-
>>> from torch._overrides import get_overridable_functions
614+
>>> from torch.overrides import get_overridable_functions
615615
>>> func_dict = get_overridable_functions()
616616
>>> nn_funcs = func_dict[torch.nn.functional]
617617
>>> print([f.__name__ for f in nn_funcs[:5])
@@ -622,20 +622,20 @@ This listing of functions makes it possible to iterate over all overridable
622622
functions, however in practice this is not enough to write tests for all of
623623
these functions without laboriously and manually copying the signature of each
624624
function for each test. To ease this process, the
625-
``torch._overrides.get_testing_overrides`` function returns a dictionary mapping
625+
``torch.overrides.get_testing_overrides`` function returns a dictionary mapping
626626
overridable functions in the ``PyTorch`` API to dummy lambda functions that have
627627
the same signature as the original function but unconditionally return -1. These
628628
functions are most useful to use with ``inspect`` to analyze the function
629629
signature of the original ``PyTorch`` function::
630630

631631
>>> import inspect
632-
>>> from torch._overrides import get_testing_overrides
632+
>>> from torch.overrides import get_testing_overrides
633633
>>> override_dict = get_testing_overrides()
634634
>>> dummy_add = override_dict[torch.add]
635635
>>> inspect.signature(dummy_add)
636636
<Signature (input, other, out=None)>
637637

638-
Finally, ``torch._overrides.get_ignored_functions`` returns a tuple of functions
638+
Finally, ``torch.overrides.get_ignored_functions`` returns a tuple of functions
639639
that explicitly cannot be overrided by ``__torch_function__``. This list can be
640640
useful to confirm that a function that isn't present in the dictionary returned
641641
by ``get_overridable_functions`` cannot be overriden.

0 commit comments

Comments
 (0)