1 // Copyright © 2022 Apple Inc. 2 3 #include <ATen/detail/MPSHooksInterface.h> 4 #include <c10/util/CallOnce.h> 5 6 namespace at { 7 namespace detail { 8 getMPSHooks()9const MPSHooksInterface& getMPSHooks() { 10 static std::unique_ptr<MPSHooksInterface> mps_hooks; 11 #if !defined C10_MOBILE 12 static c10::once_flag once; 13 c10::call_once(once, [] { 14 mps_hooks = MPSHooksRegistry()->Create("MPSHooks", MPSHooksArgs{}); 15 if (!mps_hooks) { 16 mps_hooks = std::make_unique<MPSHooksInterface>(); 17 } 18 }); 19 #else 20 if (mps_hooks == nullptr) { 21 mps_hooks = std::make_unique<MPSHooksInterface>(); 22 } 23 #endif 24 return *mps_hooks; 25 } 26 } // namespace detail 27 28 C10_DEFINE_REGISTRY(MPSHooksRegistry, MPSHooksInterface, MPSHooksArgs) 29 30 } // namespace at 31