[JIT] Improve source attribution for NamedTuple type inference (#95761)

Most errors thrown during torchscript scripting or execution have a SourceRange attached that can be used to identify where the error is coming from. NamedTuple type inference previously didn't have SourceRanges attached; this PR adds them.

Differential Revision: [D43685662](https://our.internmc.facebook.com/intern/diff/D43685662)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/95761
Approved by: https://github.com/eellison
This commit is contained in:
David Berard
2023-02-28 21:33:48 -08:00
committed by PyTorch MergeBot
parent 053205aab5
commit b35e67142c
3 changed files with 25 additions and 7 deletions

View File

@ -1012,7 +1012,7 @@ TypePtr registerNamedTuple(const py::object& obj, const SourceRange& loc) {
py::module::import("torch._jit_internal").attr("_qualified_name")(obj)));
py::object props = py::module::import("torch._jit_internal")
.attr("_get_named_tuple_properties")(obj);
.attr("_get_named_tuple_properties")(obj, loc);
std::string unqualName;
std::vector<std::string> field_names;