Skip to content

Commit

Permalink
[PyTorch] Remove unnecessary shared_ptr copies in ThreadLocalDebugInf…
Browse files Browse the repository at this point in the history
…o::get (#47791)

Summary:
Pull Request resolved: #47791

`debug_info` is `thread_local` and this function is a leaf, so nobody else could free it out from under us. Regular pointer should be fine.
ghstack-source-id: 116456975

Test Plan: Run framework overhead benchmarks

Reviewed By: bhosmer

Differential Revision: D24901749

fbshipit-source-id: c01a60b609fd08e5200264d8e98d356e2c78cf28
  • Loading branch information
swolchok authored and facebook-github-bot committed Nov 13, 2020
1 parent b787e74 commit 1aeac97
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions c10/util/ThreadLocalDebugInfo.cpp
Expand Up @@ -9,12 +9,12 @@ thread_local std::shared_ptr<ThreadLocalDebugInfo> debug_info = nullptr;
/* static */
std::shared_ptr<DebugInfoBase> ThreadLocalDebugInfo::get(
DebugInfoKind kind) {
auto cur = debug_info;
ThreadLocalDebugInfo* cur = debug_info.get();
while (cur) {
if (cur->kind_ == kind) {
return cur->info_;
}
cur = cur->parent_info_;
cur = cur->parent_info_.get();
}
return nullptr;
}
Expand Down

0 comments on commit 1aeac97

Please sign in to comment.