• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <ATen/detail/MAIAHooksInterface.h>
2 
3 #include <c10/util/CallOnce.h>
4 #include <c10/util/Registry.h>
5 
6 #include <cstddef>
7 #include <memory>
8 
9 namespace at {
10 namespace detail {
11 
12 // See getCUDAHooks for some more commentary
getMAIAHooks()13 const MAIAHooksInterface& getMAIAHooks() {
14   static std::unique_ptr<MAIAHooksInterface> maia_hooks;
15   static c10::once_flag once;
16   c10::call_once(once, [] {
17     maia_hooks = MAIAHooksRegistry()->Create("MAIAHooks", {});
18     if (!maia_hooks) {
19       maia_hooks = std::make_unique<MAIAHooksInterface>();
20     }
21   });
22   return *maia_hooks;
23 }
24 } // namespace detail
25 
26 // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
27 C10_DEFINE_REGISTRY(MAIAHooksRegistry, MAIAHooksInterface, MAIAHooksArgs)
28 
29 } // namespace at
30