Support named tuple return from operators on JIT (#16253)
authorXiang Gao <qasdfgtyuiop@gmail.com>
Mon, 11 Feb 2019 02:10:59 +0000 (18:10 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Mon, 11 Feb 2019 02:15:56 +0000 (18:15 -0800)
commiteae139e18fb575a8f6a0d2e43ff2f93ffe1acfde
tree4d1096dde9068b7cdb82070e4dfcb0b649226fec
parent9cb41e5386fcd2cfe9caadbe2b9285b63fb5158e
Support named tuple return from operators on JIT (#16253)

Summary:
Fixes: https://github.com/pytorch/pytorch/issues/16233

The following changes are made:
- Modify `TupleType` to store optional field names
- Modify schema matching to return fill in those field names when creating  `TupleType` as return type.
- Modify codegen of JIT to copy field names to schema string
- Modify `SchemaParser` to set field names of returned schema.
- Modify `SimpleValue::attr` to emit tuple indexing for named tuple.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16253

Reviewed By: ezyang

Differential Revision: D13954298

Pulled By: zdevito

fbshipit-source-id: 247d483d78a0c9c12d1ba36e1f1ec6c3f1a3007b
aten/src/ATen/core/jit_type.h
test/test_jit.py
tools/jit/gen_jit_dispatch.py
torch/csrc/jit/ir.cpp
torch/csrc/jit/ir.h
torch/csrc/jit/operator.cpp
torch/csrc/jit/script/schema_matching.cpp
torch/csrc/jit/script/schema_matching.h
torch/csrc/jit/script/sugared_value.cpp