numba-cuda 0.19.1__py3-none-any.whl → 0.20.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of numba-cuda might be problematic. Click here for more details.
- numba_cuda/VERSION +1 -1
- numba_cuda/numba/cuda/__init__.py +1 -1
- numba_cuda/numba/cuda/_internal/cuda_bf16.py +12706 -1470
- numba_cuda/numba/cuda/_internal/cuda_fp16.py +2653 -8769
- numba_cuda/numba/cuda/api.py +6 -1
- numba_cuda/numba/cuda/bf16.py +285 -2
- numba_cuda/numba/cuda/cgutils.py +2 -2
- numba_cuda/numba/cuda/cloudpickle/__init__.py +21 -0
- numba_cuda/numba/cuda/cloudpickle/cloudpickle.py +1598 -0
- numba_cuda/numba/cuda/cloudpickle/cloudpickle_fast.py +17 -0
- numba_cuda/numba/cuda/codegen.py +1 -1
- numba_cuda/numba/cuda/compiler.py +373 -30
- numba_cuda/numba/cuda/core/analysis.py +319 -0
- numba_cuda/numba/cuda/core/annotations/__init__.py +0 -0
- numba_cuda/numba/cuda/core/annotations/type_annotations.py +304 -0
- numba_cuda/numba/cuda/core/base.py +1289 -0
- numba_cuda/numba/cuda/core/bytecode.py +727 -0
- numba_cuda/numba/cuda/core/caching.py +2 -2
- numba_cuda/numba/cuda/core/compiler.py +6 -14
- numba_cuda/numba/cuda/core/compiler_machinery.py +497 -0
- numba_cuda/numba/cuda/core/config.py +747 -0
- numba_cuda/numba/cuda/core/consts.py +124 -0
- numba_cuda/numba/cuda/core/cpu.py +370 -0
- numba_cuda/numba/cuda/core/environment.py +68 -0
- numba_cuda/numba/cuda/core/event.py +511 -0
- numba_cuda/numba/cuda/core/funcdesc.py +330 -0
- numba_cuda/numba/cuda/core/inline_closurecall.py +1889 -0
- numba_cuda/numba/cuda/core/interpreter.py +48 -26
- numba_cuda/numba/cuda/core/ir_utils.py +15 -26
- numba_cuda/numba/cuda/core/options.py +262 -0
- numba_cuda/numba/cuda/core/postproc.py +249 -0
- numba_cuda/numba/cuda/core/pythonapi.py +1868 -0
- numba_cuda/numba/cuda/core/rewrites/__init__.py +26 -0
- numba_cuda/numba/cuda/core/rewrites/ir_print.py +90 -0
- numba_cuda/numba/cuda/core/rewrites/registry.py +104 -0
- numba_cuda/numba/cuda/core/rewrites/static_binop.py +40 -0
- numba_cuda/numba/cuda/core/rewrites/static_getitem.py +187 -0
- numba_cuda/numba/cuda/core/rewrites/static_raise.py +98 -0
- numba_cuda/numba/cuda/core/ssa.py +496 -0
- numba_cuda/numba/cuda/core/targetconfig.py +329 -0
- numba_cuda/numba/cuda/core/tracing.py +231 -0
- numba_cuda/numba/cuda/core/transforms.py +952 -0
- numba_cuda/numba/cuda/core/typed_passes.py +738 -7
- numba_cuda/numba/cuda/core/typeinfer.py +1948 -0
- numba_cuda/numba/cuda/core/unsafe/__init__.py +0 -0
- numba_cuda/numba/cuda/core/unsafe/bytes.py +67 -0
- numba_cuda/numba/cuda/core/unsafe/eh.py +66 -0
- numba_cuda/numba/cuda/core/unsafe/refcount.py +98 -0
- numba_cuda/numba/cuda/core/untyped_passes.py +1983 -0
- numba_cuda/numba/cuda/cpython/cmathimpl.py +560 -0
- numba_cuda/numba/cuda/cpython/mathimpl.py +499 -0
- numba_cuda/numba/cuda/cpython/numbers.py +1474 -0
- numba_cuda/numba/cuda/cuda_paths.py +422 -246
- numba_cuda/numba/cuda/cudadecl.py +1 -1
- numba_cuda/numba/cuda/cudadrv/__init__.py +1 -1
- numba_cuda/numba/cuda/cudadrv/devicearray.py +2 -1
- numba_cuda/numba/cuda/cudadrv/driver.py +11 -140
- numba_cuda/numba/cuda/cudadrv/dummyarray.py +111 -24
- numba_cuda/numba/cuda/cudadrv/libs.py +5 -5
- numba_cuda/numba/cuda/cudadrv/mappings.py +1 -1
- numba_cuda/numba/cuda/cudadrv/nvrtc.py +19 -8
- numba_cuda/numba/cuda/cudadrv/nvvm.py +1 -4
- numba_cuda/numba/cuda/cudadrv/runtime.py +1 -1
- numba_cuda/numba/cuda/cudaimpl.py +5 -1
- numba_cuda/numba/cuda/debuginfo.py +85 -2
- numba_cuda/numba/cuda/decorators.py +3 -3
- numba_cuda/numba/cuda/descriptor.py +3 -4
- numba_cuda/numba/cuda/deviceufunc.py +66 -2
- numba_cuda/numba/cuda/dispatcher.py +18 -39
- numba_cuda/numba/cuda/flags.py +141 -1
- numba_cuda/numba/cuda/fp16.py +0 -2
- numba_cuda/numba/cuda/include/13/cuda_bf16.h +5118 -0
- numba_cuda/numba/cuda/include/13/cuda_bf16.hpp +3865 -0
- numba_cuda/numba/cuda/include/13/cuda_fp16.h +5363 -0
- numba_cuda/numba/cuda/include/13/cuda_fp16.hpp +3483 -0
- numba_cuda/numba/cuda/lowering.py +7 -144
- numba_cuda/numba/cuda/mathimpl.py +2 -1
- numba_cuda/numba/cuda/memory_management/nrt.py +43 -17
- numba_cuda/numba/cuda/misc/findlib.py +75 -0
- numba_cuda/numba/cuda/models.py +9 -1
- numba_cuda/numba/cuda/np/npdatetime_helpers.py +217 -0
- numba_cuda/numba/cuda/np/npyfuncs.py +1807 -0
- numba_cuda/numba/cuda/np/numpy_support.py +553 -0
- numba_cuda/numba/cuda/np/ufunc/ufuncbuilder.py +59 -0
- numba_cuda/numba/cuda/nvvmutils.py +1 -1
- numba_cuda/numba/cuda/printimpl.py +12 -1
- numba_cuda/numba/cuda/random.py +1 -1
- numba_cuda/numba/cuda/serialize.py +1 -1
- numba_cuda/numba/cuda/simulator/__init__.py +1 -1
- numba_cuda/numba/cuda/simulator/api.py +1 -1
- numba_cuda/numba/cuda/simulator/compiler.py +4 -0
- numba_cuda/numba/cuda/simulator/cudadrv/devicearray.py +1 -1
- numba_cuda/numba/cuda/simulator/kernelapi.py +1 -1
- numba_cuda/numba/cuda/simulator/memory_management/nrt.py +14 -2
- numba_cuda/numba/cuda/target.py +35 -17
- numba_cuda/numba/cuda/testing.py +4 -19
- numba_cuda/numba/cuda/tests/__init__.py +1 -1
- numba_cuda/numba/cuda/tests/cloudpickle_main_class.py +9 -0
- numba_cuda/numba/cuda/tests/core/test_serialize.py +4 -4
- numba_cuda/numba/cuda/tests/cudadrv/test_cuda_devicerecord.py +1 -1
- numba_cuda/numba/cuda/tests/cudadrv/test_cuda_libraries.py +1 -1
- numba_cuda/numba/cuda/tests/cudadrv/test_deallocations.py +1 -1
- numba_cuda/numba/cuda/tests/cudadrv/test_detect.py +6 -3
- numba_cuda/numba/cuda/tests/cudadrv/test_emm_plugins.py +1 -1
- numba_cuda/numba/cuda/tests/cudadrv/test_linker.py +18 -2
- numba_cuda/numba/cuda/tests/cudadrv/test_module_callbacks.py +2 -1
- numba_cuda/numba/cuda/tests/cudadrv/test_nvjitlink.py +1 -1
- numba_cuda/numba/cuda/tests/cudadrv/test_ptds.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/extensions_usecases.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_array.py +2 -1
- numba_cuda/numba/cuda/tests/cudapy/test_atomics.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_bfloat16.py +539 -2
- numba_cuda/numba/cuda/tests/cudapy/test_bfloat16_bindings.py +81 -1
- numba_cuda/numba/cuda/tests/cudapy/test_caching.py +1 -3
- numba_cuda/numba/cuda/tests/cudapy/test_complex.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_constmem.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_cooperative_groups.py +2 -3
- numba_cuda/numba/cuda/tests/cudapy/test_copy_propagate.py +130 -0
- numba_cuda/numba/cuda/tests/cudapy/test_datetime.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_debug.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_debuginfo.py +293 -4
- numba_cuda/numba/cuda/tests/cudapy/test_debuginfo_types.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_dispatcher.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_errors.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_exception.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_extending.py +2 -1
- numba_cuda/numba/cuda/tests/cudapy/test_inline.py +18 -8
- numba_cuda/numba/cuda/tests/cudapy/test_ir_utils.py +10 -37
- numba_cuda/numba/cuda/tests/cudapy/test_laplace.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_math.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_matmul.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_operator.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_print.py +20 -0
- numba_cuda/numba/cuda/tests/cudapy/test_record_dtype.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_reduction.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_serialize.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_sm.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_ssa.py +453 -0
- numba_cuda/numba/cuda/tests/cudapy/test_sync.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_typeinfer.py +538 -0
- numba_cuda/numba/cuda/tests/cudapy/test_ufuncs.py +263 -2
- numba_cuda/numba/cuda/tests/cudapy/test_userexc.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_vector_type.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_vectorize_decor.py +112 -6
- numba_cuda/numba/cuda/tests/cudapy/test_warning.py +1 -1
- numba_cuda/numba/cuda/tests/cudapy/test_warp_ops.py +1 -1
- numba_cuda/numba/cuda/tests/doc_examples/test_cg.py +0 -2
- numba_cuda/numba/cuda/tests/doc_examples/test_ffi.py +3 -2
- numba_cuda/numba/cuda/tests/doc_examples/test_laplace.py +0 -2
- numba_cuda/numba/cuda/tests/doc_examples/test_sessionize.py +0 -2
- numba_cuda/numba/cuda/tests/nocuda/test_import.py +3 -1
- numba_cuda/numba/cuda/tests/nocuda/test_library_lookup.py +24 -12
- numba_cuda/numba/cuda/tests/nrt/test_nrt.py +2 -1
- numba_cuda/numba/cuda/tests/support.py +55 -15
- numba_cuda/numba/cuda/tests/test_tracing.py +200 -0
- numba_cuda/numba/cuda/types.py +56 -0
- numba_cuda/numba/cuda/typing/__init__.py +9 -1
- numba_cuda/numba/cuda/typing/cffi_utils.py +55 -0
- numba_cuda/numba/cuda/typing/context.py +751 -0
- numba_cuda/numba/cuda/typing/enumdecl.py +74 -0
- numba_cuda/numba/cuda/typing/npydecl.py +658 -0
- numba_cuda/numba/cuda/typing/templates.py +7 -6
- numba_cuda/numba/cuda/ufuncs.py +3 -3
- numba_cuda/numba/cuda/utils.py +6 -112
- {numba_cuda-0.19.1.dist-info → numba_cuda-0.20.0.dist-info}/METADATA +2 -1
- {numba_cuda-0.19.1.dist-info → numba_cuda-0.20.0.dist-info}/RECORD +170 -115
- numba_cuda/numba/cuda/tests/cudadrv/test_mvc.py +0 -60
- {numba_cuda-0.19.1.dist-info → numba_cuda-0.20.0.dist-info}/WHEEL +0 -0
- {numba_cuda-0.19.1.dist-info → numba_cuda-0.20.0.dist-info}/licenses/LICENSE +0 -0
- {numba_cuda-0.19.1.dist-info → numba_cuda-0.20.0.dist-info}/licenses/LICENSE.numba +0 -0
- {numba_cuda-0.19.1.dist-info → numba_cuda-0.20.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: BSD-2-Clause
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Function descriptors.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from collections import defaultdict
|
|
9
|
+
import importlib
|
|
10
|
+
|
|
11
|
+
from numba.core import types
|
|
12
|
+
from numba.cuda import itanium_mangler
|
|
13
|
+
from numba.cuda.utils import _dynamic_modname, _dynamic_module
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def default_mangler(name, argtypes, *, abi_tags=(), uid=None):
|
|
17
|
+
return itanium_mangler.mangle(name, argtypes, abi_tags=abi_tags, uid=uid)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def qualifying_prefix(modname, qualname):
|
|
21
|
+
"""
|
|
22
|
+
Returns a new string that is used for the first half of the mangled name.
|
|
23
|
+
"""
|
|
24
|
+
# XXX choose a different convention for object mode
|
|
25
|
+
return "{}.{}".format(modname, qualname) if modname else qualname
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class FunctionDescriptor(object):
|
|
29
|
+
"""
|
|
30
|
+
Base class for function descriptors: an object used to carry
|
|
31
|
+
useful metadata about a natively callable function.
|
|
32
|
+
|
|
33
|
+
Note that while `FunctionIdentity` denotes a Python function
|
|
34
|
+
which is being concretely compiled by Numba, `FunctionDescriptor`
|
|
35
|
+
may be more "abstract".
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
__slots__ = (
|
|
39
|
+
"native",
|
|
40
|
+
"modname",
|
|
41
|
+
"qualname",
|
|
42
|
+
"doc",
|
|
43
|
+
"typemap",
|
|
44
|
+
"calltypes",
|
|
45
|
+
"args",
|
|
46
|
+
"kws",
|
|
47
|
+
"restype",
|
|
48
|
+
"argtypes",
|
|
49
|
+
"mangled_name",
|
|
50
|
+
"unique_name",
|
|
51
|
+
"env_name",
|
|
52
|
+
"global_dict",
|
|
53
|
+
"inline",
|
|
54
|
+
"noalias",
|
|
55
|
+
"abi_tags",
|
|
56
|
+
"uid",
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
def __init__(
|
|
60
|
+
self,
|
|
61
|
+
native,
|
|
62
|
+
modname,
|
|
63
|
+
qualname,
|
|
64
|
+
unique_name,
|
|
65
|
+
doc,
|
|
66
|
+
typemap,
|
|
67
|
+
restype,
|
|
68
|
+
calltypes,
|
|
69
|
+
args,
|
|
70
|
+
kws,
|
|
71
|
+
mangler=None,
|
|
72
|
+
argtypes=None,
|
|
73
|
+
inline=False,
|
|
74
|
+
noalias=False,
|
|
75
|
+
env_name=None,
|
|
76
|
+
global_dict=None,
|
|
77
|
+
abi_tags=(),
|
|
78
|
+
uid=None,
|
|
79
|
+
):
|
|
80
|
+
self.native = native
|
|
81
|
+
self.modname = modname
|
|
82
|
+
self.global_dict = global_dict
|
|
83
|
+
self.qualname = qualname
|
|
84
|
+
self.unique_name = unique_name
|
|
85
|
+
self.doc = doc
|
|
86
|
+
# XXX typemap and calltypes should be on the compile result,
|
|
87
|
+
# not the FunctionDescriptor
|
|
88
|
+
self.typemap = typemap
|
|
89
|
+
self.calltypes = calltypes
|
|
90
|
+
self.args = args
|
|
91
|
+
self.kws = kws
|
|
92
|
+
self.restype = restype
|
|
93
|
+
# Argument types
|
|
94
|
+
if argtypes is not None:
|
|
95
|
+
assert isinstance(argtypes, tuple), argtypes
|
|
96
|
+
self.argtypes = argtypes
|
|
97
|
+
else:
|
|
98
|
+
# Get argument types from the type inference result
|
|
99
|
+
# (note the "arg.FOO" convention as used in typeinfer
|
|
100
|
+
self.argtypes = tuple(self.typemap["arg." + a] for a in args)
|
|
101
|
+
mangler = default_mangler if mangler is None else mangler
|
|
102
|
+
# The mangled name *must* be unique, else the wrong function can
|
|
103
|
+
# be chosen at link time.
|
|
104
|
+
qualprefix = qualifying_prefix(self.modname, self.qualname)
|
|
105
|
+
self.uid = uid
|
|
106
|
+
self.mangled_name = mangler(
|
|
107
|
+
qualprefix,
|
|
108
|
+
self.argtypes,
|
|
109
|
+
abi_tags=abi_tags,
|
|
110
|
+
uid=uid,
|
|
111
|
+
)
|
|
112
|
+
if env_name is None:
|
|
113
|
+
env_name = mangler(
|
|
114
|
+
".NumbaEnv.{}".format(qualprefix),
|
|
115
|
+
self.argtypes,
|
|
116
|
+
abi_tags=abi_tags,
|
|
117
|
+
uid=uid,
|
|
118
|
+
)
|
|
119
|
+
self.env_name = env_name
|
|
120
|
+
self.inline = inline
|
|
121
|
+
self.noalias = noalias
|
|
122
|
+
self.abi_tags = abi_tags
|
|
123
|
+
|
|
124
|
+
def lookup_globals(self):
|
|
125
|
+
"""
|
|
126
|
+
Return the global dictionary of the function.
|
|
127
|
+
It may not match the Module's globals if the function is created
|
|
128
|
+
dynamically (i.e. exec)
|
|
129
|
+
"""
|
|
130
|
+
return self.global_dict or self.lookup_module().__dict__
|
|
131
|
+
|
|
132
|
+
def lookup_module(self):
|
|
133
|
+
"""
|
|
134
|
+
Return the module in which this function is supposed to exist.
|
|
135
|
+
This may be a dummy module if the function was dynamically
|
|
136
|
+
generated or the module can't be found.
|
|
137
|
+
"""
|
|
138
|
+
if self.modname == _dynamic_modname:
|
|
139
|
+
return _dynamic_module
|
|
140
|
+
else:
|
|
141
|
+
try:
|
|
142
|
+
# ensure module exist
|
|
143
|
+
return importlib.import_module(self.modname)
|
|
144
|
+
except ImportError:
|
|
145
|
+
return _dynamic_module
|
|
146
|
+
|
|
147
|
+
def lookup_function(self):
|
|
148
|
+
"""
|
|
149
|
+
Return the original function object described by this object.
|
|
150
|
+
"""
|
|
151
|
+
return getattr(self.lookup_module(), self.qualname)
|
|
152
|
+
|
|
153
|
+
@property
|
|
154
|
+
def llvm_func_name(self):
|
|
155
|
+
"""
|
|
156
|
+
The LLVM-registered name for the raw function.
|
|
157
|
+
"""
|
|
158
|
+
return self.mangled_name
|
|
159
|
+
|
|
160
|
+
@property
|
|
161
|
+
def llvm_cpython_wrapper_name(self):
|
|
162
|
+
"""
|
|
163
|
+
The LLVM-registered name for a CPython-compatible wrapper of the
|
|
164
|
+
raw function (i.e. a PyCFunctionWithKeywords).
|
|
165
|
+
"""
|
|
166
|
+
return itanium_mangler.prepend_namespace(
|
|
167
|
+
self.mangled_name, ns="cpython"
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
@property
|
|
171
|
+
def llvm_cfunc_wrapper_name(self):
|
|
172
|
+
"""
|
|
173
|
+
The LLVM-registered name for a C-compatible wrapper of the
|
|
174
|
+
raw function.
|
|
175
|
+
"""
|
|
176
|
+
return "cfunc." + self.mangled_name
|
|
177
|
+
|
|
178
|
+
def __repr__(self):
|
|
179
|
+
return "<function descriptor %r>" % (self.unique_name)
|
|
180
|
+
|
|
181
|
+
@classmethod
|
|
182
|
+
def _get_function_info(cls, func_ir):
|
|
183
|
+
"""
|
|
184
|
+
Returns
|
|
185
|
+
-------
|
|
186
|
+
qualname, unique_name, modname, doc, args, kws, globals
|
|
187
|
+
|
|
188
|
+
``unique_name`` must be a unique name.
|
|
189
|
+
"""
|
|
190
|
+
func = func_ir.func_id.func
|
|
191
|
+
qualname = func_ir.func_id.func_qualname
|
|
192
|
+
# XXX to func_id
|
|
193
|
+
modname = func.__module__
|
|
194
|
+
doc = func.__doc__ or ""
|
|
195
|
+
args = tuple(func_ir.arg_names)
|
|
196
|
+
kws = () # TODO
|
|
197
|
+
global_dict = None
|
|
198
|
+
|
|
199
|
+
if modname is None:
|
|
200
|
+
# Dynamically generated function.
|
|
201
|
+
modname = _dynamic_modname
|
|
202
|
+
# Retain a reference to the dictionary of the function.
|
|
203
|
+
# This disables caching, serialization and pickling.
|
|
204
|
+
global_dict = func_ir.func_id.func.__globals__
|
|
205
|
+
|
|
206
|
+
unique_name = func_ir.func_id.unique_name
|
|
207
|
+
|
|
208
|
+
return qualname, unique_name, modname, doc, args, kws, global_dict
|
|
209
|
+
|
|
210
|
+
@classmethod
|
|
211
|
+
def _from_python_function(
|
|
212
|
+
cls,
|
|
213
|
+
func_ir,
|
|
214
|
+
typemap,
|
|
215
|
+
restype,
|
|
216
|
+
calltypes,
|
|
217
|
+
native,
|
|
218
|
+
mangler=None,
|
|
219
|
+
inline=False,
|
|
220
|
+
noalias=False,
|
|
221
|
+
abi_tags=(),
|
|
222
|
+
):
|
|
223
|
+
(
|
|
224
|
+
qualname,
|
|
225
|
+
unique_name,
|
|
226
|
+
modname,
|
|
227
|
+
doc,
|
|
228
|
+
args,
|
|
229
|
+
kws,
|
|
230
|
+
global_dict,
|
|
231
|
+
) = cls._get_function_info(func_ir)
|
|
232
|
+
|
|
233
|
+
self = cls(
|
|
234
|
+
native,
|
|
235
|
+
modname,
|
|
236
|
+
qualname,
|
|
237
|
+
unique_name,
|
|
238
|
+
doc,
|
|
239
|
+
typemap,
|
|
240
|
+
restype,
|
|
241
|
+
calltypes,
|
|
242
|
+
args,
|
|
243
|
+
kws,
|
|
244
|
+
mangler=mangler,
|
|
245
|
+
inline=inline,
|
|
246
|
+
noalias=noalias,
|
|
247
|
+
global_dict=global_dict,
|
|
248
|
+
abi_tags=abi_tags,
|
|
249
|
+
uid=func_ir.func_id.unique_id,
|
|
250
|
+
)
|
|
251
|
+
return self
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
class PythonFunctionDescriptor(FunctionDescriptor):
|
|
255
|
+
"""
|
|
256
|
+
A FunctionDescriptor subclass for Numba-compiled functions.
|
|
257
|
+
"""
|
|
258
|
+
|
|
259
|
+
__slots__ = ()
|
|
260
|
+
|
|
261
|
+
@classmethod
|
|
262
|
+
def from_specialized_function(
|
|
263
|
+
cls,
|
|
264
|
+
func_ir,
|
|
265
|
+
typemap,
|
|
266
|
+
restype,
|
|
267
|
+
calltypes,
|
|
268
|
+
mangler,
|
|
269
|
+
inline,
|
|
270
|
+
noalias,
|
|
271
|
+
abi_tags,
|
|
272
|
+
):
|
|
273
|
+
"""
|
|
274
|
+
Build a FunctionDescriptor for a given specialization of a Python
|
|
275
|
+
function (in nopython mode).
|
|
276
|
+
"""
|
|
277
|
+
return cls._from_python_function(
|
|
278
|
+
func_ir,
|
|
279
|
+
typemap,
|
|
280
|
+
restype,
|
|
281
|
+
calltypes,
|
|
282
|
+
native=True,
|
|
283
|
+
mangler=mangler,
|
|
284
|
+
inline=inline,
|
|
285
|
+
noalias=noalias,
|
|
286
|
+
abi_tags=abi_tags,
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
@classmethod
|
|
290
|
+
def from_object_mode_function(cls, func_ir):
|
|
291
|
+
"""
|
|
292
|
+
Build a FunctionDescriptor for an object mode variant of a Python
|
|
293
|
+
function.
|
|
294
|
+
"""
|
|
295
|
+
typemap = defaultdict(lambda: types.pyobject)
|
|
296
|
+
calltypes = typemap.copy()
|
|
297
|
+
restype = types.pyobject
|
|
298
|
+
return cls._from_python_function(
|
|
299
|
+
func_ir, typemap, restype, calltypes, native=False
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
class ExternalFunctionDescriptor(FunctionDescriptor):
|
|
304
|
+
"""
|
|
305
|
+
A FunctionDescriptor subclass for opaque external functions
|
|
306
|
+
(e.g. raw C functions).
|
|
307
|
+
"""
|
|
308
|
+
|
|
309
|
+
__slots__ = ()
|
|
310
|
+
|
|
311
|
+
def __init__(self, name, restype, argtypes):
|
|
312
|
+
args = ["arg%d" % i for i in range(len(argtypes))]
|
|
313
|
+
|
|
314
|
+
def mangler(a, x, abi_tags, uid=None):
|
|
315
|
+
return a
|
|
316
|
+
|
|
317
|
+
super(ExternalFunctionDescriptor, self).__init__(
|
|
318
|
+
native=True,
|
|
319
|
+
modname=None,
|
|
320
|
+
qualname=name,
|
|
321
|
+
unique_name=name,
|
|
322
|
+
doc="",
|
|
323
|
+
typemap=None,
|
|
324
|
+
restype=restype,
|
|
325
|
+
calltypes=None,
|
|
326
|
+
args=args,
|
|
327
|
+
kws=None,
|
|
328
|
+
mangler=mangler,
|
|
329
|
+
argtypes=argtypes,
|
|
330
|
+
)
|