1 #pragma once 2 3 #include <c10/macros/Macros.h> 4 5 namespace c10 { 6 7 // RAII thread local guard that tracks whether code is being executed in 8 // `at::parallel_for` or `at::parallel_reduce` loop function. 9 class C10_API ParallelGuard { 10 public: 11 static bool is_enabled(); 12 13 ParallelGuard(bool state); 14 ~ParallelGuard(); 15 16 private: 17 bool previous_state_; 18 }; 19 20 } // namespace c10 21