File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change 1
1
#include < ATen/detail/HPUHooksInterface.h>
2
2
#include < c10/util/CallOnce.h>
3
+ #include < memory>
3
4
4
5
namespace at {
5
6
namespace detail {
6
7
7
- static HPUHooksInterface* hpu_hooks = nullptr ;
8
-
9
8
TORCH_API const at::HPUHooksInterface& getHPUHooks () {
9
+ static std::unique_ptr<HPUHooksInterface> hpu_hooks;
10
10
static c10::once_flag once;
11
11
c10::call_once (once, [] {
12
- hpu_hooks =
13
- HPUHooksRegistry ()->Create (" HPUHooks" , HPUHooksArgs{}).release ();
14
- TORCH_CHECK (
15
- hpu_hooks != nullptr ,
16
- " Missing registration for HPUHooks in HPUHooksRegistry." )
12
+ hpu_hooks = HPUHooksRegistry ()->Create (" HPUHooks" , HPUHooksArgs{});
13
+ if (!hpu_hooks) {
14
+ hpu_hooks = std::make_unique<HPUHooksInterface>();
15
+ }
17
16
});
18
17
return *hpu_hooks;
19
18
}
Original file line number Diff line number Diff line change @@ -37,6 +37,11 @@ struct TORCH_API HPUHooksInterface : AcceleratorHooksInterface {
37
37
false ,
38
38
" You should register `HPUHooksInterface` for HPU before call `getPinnedMemoryAllocator`." );
39
39
}
40
+ bool hasPrimaryContext (C10_UNUSED DeviceIndex device_index) const override {
41
+ TORCH_CHECK (
42
+ false ,
43
+ " You should register `HPUHooksInterface` for HPU before call `hasPrimaryContext`." );
44
+ }
40
45
};
41
46
42
47
struct TORCH_API HPUHooksArgs {};
You can’t perform that action at this time.
0 commit comments