descriptor.py 1.59 KB
Newer Older
dugupeiwen's avatar
dugupeiwen committed
1
2
3
4
5
6
7
8
9
10
11
12
13
from numba.core.descriptors import TargetDescriptor
from numba.core.options import TargetOptions
from .target import HSATargetContext, HSATypingContext


class HSATargetOptions(TargetOptions):
    OPTIONS = {}


class HSATargetDesc(TargetDescriptor):
    options = HSATargetOptions
    typingctx = HSATypingContext()
    targetctx = HSATargetContext(typingctx)
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

    # sugon: from dispatcher.Dispatcher
    typing_context = typingctx
    target_context = targetctx


# ## sugon TODO: support ROCmDispatcher
# class HSATargetDesc(TargetDescriptor):
#     def __init__(self, name):
#         self.options = HSATargetOptions
#         # The typing and target contexts are initialized only when needed -
#         # this prevents an attempt to load CUDA libraries at import time on
#         # systems that might not have them present.
#         self._typingctx = None
#         self._targetctx = None
#         super().__init__(name)

#     @property
#     def typing_context(self):
#         if self._typingctx is None:
#             self._typingctx = HSATypingContext()
#         return self._typingctx

#     @property
#     def target_context(self):
#         if self._targetctx is None:
#             self._targetctx = HSATargetContext(self._typingctx)
#         return self._targetctx

#     @property
#     def typingctx(self):
#         if self._typingctx is None:
#             self._typingctx = HSATypingContext()
#         return self._typingctx

#     @property
#     def targetctx(self):
#         if self._targetctx is None:
#             self._targetctx = HSATargetContext(self._typingctx)
#         return self._targetctx