-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Description
🐛 Bug
If annotation is accessed through annotations.py, then an exception is raised. annotations.py pathway is used in a lot of script code and should work with named tuples.
To Reproduce
_GoogLeNetOutputs = namedtuple('GoogLeNetOutputs', ['logits', 'aux_logits2', 'aux_logits1'])
def fn(x):
# type: (Tensor) -> _GoogLeNetOutputs
return _GoogleNetOutputs(x, x, x)
print(torch.jit.annotations.get_signature(fn))
Traceback (most recent call last):
File "test/test_jit.py", line 14745, in test_named_tuple_py2
print(torch.jit.annotations.get_signature(fn))
File "/home/eellison/local/miniconda/envs/ninja/lib/python3.7/site-packages/torch/jit/annotations.py", line 59, in get_signature
return parse_type_line(type_line)
File "/home/eellison/local/miniconda/envs/ninja/lib/python3.7/site-packages/torch/jit/annotations.py", line 109, in parse_type_line
raise RuntimeError("Failed to parse the return type of a type annotation: {}".format(str(e)))
RuntimeError: Failed to parse the return type of a type annotation: name '_GoogLeNetOutputs' is not defined
cc @suo