Skip to content

Commit

Permalink
[ivalue] operator<<: don't error on invalid IValue tags (#112232)
Browse files Browse the repository at this point in the history
While running the profiler, we observed a scenario where we observe IValues with invalid tags. Specifically, we try to convert the IValue to a string here:

https://github.com/pytorch/pytorch/blob/d3bf6803b62c79f1dafd1eec49b4bd65d5a27697/torch/csrc/profiler/util.cpp#L306-L308

and in the scenario with invalid IValues, an exception gets thrown here, in `operator<<`.

https://github.com/pytorch/pytorch/blob/d3bf6803b62c79f1dafd1eec49b4bd65d5a27697/aten/src/ATen/core/ivalue.cpp#L864

IMO, `<<` shouldn't error if the IValue is bad; instead, we should just print that the IValue tag is invalid.

Differential Revision: [D50760040](https://our.internmc.facebook.com/intern/diff/D50760040)
Pull Request resolved: #112232
Approved by: https://github.com/albanD
  • Loading branch information
davidberard98 authored and pytorchmergebot committed Oct 31, 2023
1 parent c311351 commit bb97ce4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion aten/src/ATen/core/ivalue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ std::ostream& operator<<(std::ostream & out, const IValue & v) {
}

}
AT_ERROR("Tag not found: ", v.tagKind());
return out << "<Invalid IValue tag=" << std::to_string(static_cast<uint32_t>(v.tag)) << ">";
}

#undef TORCH_FORALL_TAGS
Expand Down

0 comments on commit bb97ce4

Please sign in to comment.