Skip to content

Dynamo does not support methods defined on NamedTuples #91662

@suo

Description

@suo
from typing import NamedTuple

class MyTuple(NamedTuple):
    first: torch.Tensor
    second: torch.Tensor

    def add(self):
        return first + second

def my_fn(x):
    return x.add()

torch._dynamo.export(my_fn, MyTuple(first=torch.tensor(1), second=torch.tensor(2)))

raises torch._dynamo.exc.Unsupported: NamedTupleVariable.add

cc @ezyang @soumith @msaroufim @wconstab @ngimel @bdhirsh @mlazos @voznesenskym @yanboliang @penguinwu @anijain2305 @EikanWang @jgong5 @Guobing-Chen @chunyuan-w @XiaobingSuper @zhuhaozhe @blzheng @Xia-Weiwen @wenzhe-nrv @jiayisunx @desertfire

Metadata

Metadata

Assignees

Labels

featureA request for a proper, new feature.module: dynamooncall: pt2triagedThis 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