mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Pull Request resolved: https://github.com/pytorch/pytorch/pull/120455 Approved by: https://github.com/albanD
20 lines
356 B
C++
20 lines
356 B
C++
#include <c10/util/ParallelGuard.h>
|
|
|
|
namespace c10 {
|
|
|
|
thread_local 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
|