xref: /aosp_15_r20/external/pytorch/aten/src/ATen/detail/XPUHooksInterface.cpp (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1 #include <ATen/detail/XPUHooksInterface.h>
2 
3 #include <c10/util/CallOnce.h>
4 
5 namespace at {
6 namespace detail {
7 
getXPUHooks()8 const XPUHooksInterface& getXPUHooks() {
9   static XPUHooksInterface* xpu_hooks = nullptr;
10   static c10::once_flag once;
11   c10::call_once(once, [] {
12     xpu_hooks =
13         XPUHooksRegistry()->Create("XPUHooks", XPUHooksArgs{}).release();
14     if (!xpu_hooks) {
15       xpu_hooks = new XPUHooksInterface();
16     }
17   });
18   return *xpu_hooks;
19 }
20 } // namespace detail
21 
22 C10_DEFINE_REGISTRY(XPUHooksRegistry, XPUHooksInterface, XPUHooksArgs)
23 
24 } // namespace at
25