pytorch
1d61aeb2 - [Profiler] Introduce `torch::profiler::impl::EventType`

Commit
2 years ago
[Profiler] Introduce `torch::profiler::impl::EventType` Pull Request resolved: https://github.com/pytorch/pytorch/pull/77693 Right now the profiler internals are rather ad-hoc and disjoint. As we move towards a unified experience this needs to be addressed. This PR adds an enum specifying the various types of events that can be profiled and specializes the `ExtraFields` struct on the values of the `EventType` enum. This lets us punt more of the heterogeneity onto the type system and allows a caller to simply think in terms of `ExtraFields<EventType::...>`. (No more "X field is always present but only makes sense for Y". e.g. inputs) For now only ops and backend events are transitioned since they are already in a weird union state. Changes planned for subsequent diffs in the stack: 1) Allocations 2) Python tracer events 3) Kineto (e.g. Cupti) events 4) Use unified event type for more post processing One rather pleasant observation was that this change exposed several minor bugs in the current implementation: 1) We just didn't plumb `end_thread_id_` from `OpEvent` to `Result`. Switching to using ctors rather than setting fields in `getRecords` fixes this. 2) We were calling `fn.threadId()` to get start TID, but that is wasteful because it is already stored in the `ThreadLocalSubqueue`. So that gives me some confidence that this is a step in the right direction. Differential Revision: [D36189044](https://our.internmc.facebook.com/intern/diff/D36189044/) **NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D36189044/)! Approved by: https://github.com/aaronenyeshi
Author
Taylor Robie
Committer
Parents
Loading