1 | #include <ATen/detail/HIPHooksInterface.h> |
---|---|
2 | |
3 | #include <c10/util/Exception.h> |
4 | #include <c10/util/CallOnce.h> |
5 | |
6 | #include <cstddef> |
7 | #include <memory> |
8 | #include <mutex> |
9 | |
10 | namespace at { |
11 | namespace detail { |
12 | |
13 | // See getCUDAHooks for some more commentary |
14 | const HIPHooksInterface& getHIPHooks() { |
15 | static std::unique_ptr<HIPHooksInterface> hip_hooks; |
16 | #if !defined C10_MOBILE |
17 | static c10::once_flag once; |
18 | c10::call_once(once, [] { |
19 | hip_hooks = HIPHooksRegistry()->Create("HIPHooks", HIPHooksArgs{}); |
20 | if (!hip_hooks) { |
21 | hip_hooks = std::make_unique<HIPHooksInterface>(); |
22 | } |
23 | }); |
24 | #else |
25 | if (hip_hooks == nullptr) { |
26 | hip_hooks = std::make_unique<HIPHooksInterface>(); |
27 | } |
28 | #endif |
29 | return *hip_hooks; |
30 | } |
31 | } // namespace detail |
32 | |
33 | C10_DEFINE_REGISTRY(HIPHooksRegistry, HIPHooksInterface, HIPHooksArgs) |
34 | |
35 | } // namespace at |
36 |