pytorch
c06a5586 - [Profiler] Unify global and thread local profiler lookup. (#83894)

Commit
2 years ago
[Profiler] Unify global and thread local profiler lookup. (#83894) This PR renames `ProfilerThreadLocalStateBase` to simply `ProfilerStateBase`, and adds `push`, `pop`, and `get` methods. `global` can be specified, or can be omitted for priority selection. In order to support this unification it was necessary to make a (mostly) non-throwing version of pop. The asserts around observer removal are intended to act as guard rails against multiple profilers trampling over each other. However on-demand wants to do exactly that because it wants to be able to preempt. A hack would be to get the current observer and then only pop if an observer is found, but that would be prone to race conditions. By removing the asserts, we can preserve the old behavior by adding `ASSERT(pop())` on the caller side while allowing more complex handling for the kineto client interface. (Later PR.) Differential Revision: [D38931521](https://our.internmc.facebook.com/intern/diff/D38931521/) Pull Request resolved: https://github.com/pytorch/pytorch/pull/83894 Approved by: https://github.com/slgong-fb
Author
Taylor Robie
Committer
Parents
Loading