pytorch
bd34636b - [pytorch][PR] [Profiler] Add EventFieldsVisitor

Commit
2 years ago
[pytorch][PR] [Profiler] Add EventFieldsVisitor One source of complexity in profiler_kineto is that we do most things twice: once to set a field in `kineto_events_.back()`, and once for the metadata json. These have historically been chained, with the KinetoEvent used to populate the metadata fields. However this is hard to read and error prone, as we have one giant block of assignments followed by another giant block. It also means that logic about whether a field is present or not is duplicated. This PR replaces this logic with a visitor that writes both together. E.g. ``` auto& dtypes = result_.get().inputs_.dtypes_; if (!dtypes.empty()) { kineto_event_.get().dtypes(dtypes); out.emplace_back("Input type", dtypesToStr(dtypes)); } ``` Differential Revision: [D36070202](https://our.internmc.facebook.com/intern/diff/D36070202/) Pull Request resolved: https://github.com/pytorch/pytorch/pull/77691 Approved by: https://github.com/aaronenyeshi
Author
Taylor Robie
Committer
Parents
Loading