I wonder if it’s possible to retrieve the names of the resulting output when calling a traced function, for example:
import torch
from collections import namedtuple
output = namedtuple("output", ["hello", "bye"])
def f (x):
return output(x, 2*x)
traced_fn = torch.jit.trace(f, torch.tensor(1))
traced_fn(torch.tensor(2))
Returns an unamed tuple:
(tensor(2), tensor(4))
I know I can return a dictionary and disable strict
, to get named outputs but would like to know if this this possible with named tuples.