mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Add torch.dtype instances to the public API (#119307)
Fixes #91908 Pull Request resolved: https://github.com/pytorch/pytorch/pull/119307 Approved by: https://github.com/albanD
This commit is contained in:
committed by
PyTorch MergeBot
parent
8c2fde1fcf
commit
45a79323fe
@ -460,7 +460,8 @@ class TestPublicBindings(TestCase):
|
||||
# verifies that each public API has the correct module name and naming semantics
|
||||
def check_one_element(elem, modname, mod, *, is_public, is_all):
|
||||
obj = getattr(mod, elem)
|
||||
if not (isinstance(obj, Callable) or inspect.isclass(obj)):
|
||||
# torch.dtype is not a class nor callable, so we need to check for it separately
|
||||
if not (isinstance(obj, (Callable, torch.dtype)) or inspect.isclass(obj)):
|
||||
return
|
||||
elem_module = getattr(obj, '__module__', None)
|
||||
# Only used for nice error message below
|
||||
|
@ -1513,6 +1513,15 @@ for name in dir(_C._VariableFunctions):
|
||||
__all__.append(name)
|
||||
|
||||
|
||||
################################################################################
|
||||
# Add torch.dtype instances to the public API
|
||||
################################################################################
|
||||
|
||||
import torch
|
||||
|
||||
for attribute in dir(torch):
|
||||
if isinstance(getattr(torch, attribute), torch.dtype):
|
||||
__all__.append(attribute)
|
||||
|
||||
################################################################################
|
||||
# Import TorchDynamo's lazy APIs to avoid circular dependenices
|
||||
|
Reference in New Issue
Block a user