mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Re-check some files and mark variables and functions into static and fix other warnings. Pull Request resolved: https://github.com/pytorch/pytorch/pull/136847 Approved by: https://github.com/ezyang
20 lines
363 B
C++
20 lines
363 B
C++
#include <c10/util/ParallelGuard.h>
|
|
|
|
namespace c10 {
|
|
|
|
thread_local static bool in_at_parallel = false;
|
|
|
|
bool ParallelGuard::is_enabled() {
|
|
return in_at_parallel;
|
|
}
|
|
|
|
ParallelGuard::ParallelGuard(bool state) : previous_state_(is_enabled()) {
|
|
in_at_parallel = state;
|
|
}
|
|
|
|
ParallelGuard::~ParallelGuard() {
|
|
in_at_parallel = previous_state_;
|
|
}
|
|
|
|
} // namespace c10
|