Hello,
To give some context, I am building a numpy array of jit-compiled functions addresses.
I use these addresses to dynamically call the functions.
(venv-3.13) ➜ nucs git:(main) ✗ cat requirements.txt
numba==0.61.0rc2
numpy==2.1.3
…
(venv-3.13) ➜ nucs git:(main) ✗ cat nucs/numba_helper.py
from typing import List
from numba import types # type: ignore
from numba.core import cgutils
from numba.experimental.function_type import _get_wrapper_address
from numba.extending import intrinsic
@intrinsic
def function_from_address(typingctx, func_type_ref: types.FunctionType, addr: int): # type: ignore
“”"
Recovers a function from FunctionType and address.
“”"
func_type = func_type_ref.instance_type
def codegen(context, builder, sig, args): # type: ignore
_, address = args
sfunc = cgutils.create_struct_proxy(func_type)(context, builder)
sfunc.addr = builder.inttoptr(address, context.get_value_type(types.voidptr))
return sfunc._getvalue()
return func_type(func_type_ref, addr), codegen
def build_function_address_list(functions, signature) → List[int]: # type: ignore
return [_get_wrapper_address(function, signature) for function in functions]
When I run some tests, I get:
…
nucs/numba_helper.py:38: in build_function_address_list
return [_get_wrapper_address(function, signature) for function in functions]
venv-3.13/lib/python3.13/site-packages/numba/experimental/function_type.py:159: in _get_wrapper_address
cres = func.get_compile_result(sig)
venv-3.13/lib/python3.13/site-packages/numba/core/dispatcher.py:925: in get_compile_result
self.compile(atypes)
venv-3.13/lib/python3.13/site-packages/numba/core/dispatcher.py:904: in compile
cres = self._compiler.compile(args, return_type)
venv-3.13/lib/python3.13/site-packages/numba/core/dispatcher.py:80: in compile
status, retval = self._compile_cached(args, return_type)
venv-3.13/lib/python3.13/site-packages/numba/core/dispatcher.py:94: in _compile_cached
retval = self._compile_core(args, return_type)
venv-3.13/lib/python3.13/site-packages/numba/core/dispatcher.py:107: in _compile_core
cres = compiler.compile_extra(self.targetdescr.typing_context,
venv-3.13/lib/python3.13/site-packages/numba/core/compiler.py:739: in compile_extra
return pipeline.compile_extra(func)
venv-3.13/lib/python3.13/site-packages/numba/core/compiler.py:439: in compile_extra
return self._compile_bytecode()
venv-3.13/lib/python3.13/site-packages/numba/core/compiler.py:505: in _compile_bytecode
return self._compile_core()
venv-3.13/lib/python3.13/site-packages/numba/core/compiler.py:481: in _compile_core
raise e
venv-3.13/lib/python3.13/site-packages/numba/core/compiler.py:473: in _compile_core
pm.run(self.state)
venv-3.13/lib/python3.13/site-packages/numba/core/compiler_machinery.py:363: in run
raise e
venv-3.13/lib/python3.13/site-packages/numba/core/compiler_machinery.py:356: in run
self._runPass(idx, pass_inst, state)
venv-3.13/lib/python3.13/site-packages/numba/core/compiler_lock.py:35: in _acquire_compile_lock
return func(*args, **kwargs)
venv-3.13/lib/python3.13/site-packages/numba/core/compiler_machinery.py:311: in _runPass
mutated |= check(pss.run_pass, internal_state)
venv-3.13/lib/python3.13/site-packages/numba/core/compiler_machinery.py:272: in check
mangled = func(compiler_state)
venv-3.13/lib/python3.13/site-packages/numba/core/typed_passes.py:468: in run_pass
lower.lower()
venv-3.13/lib/python3.13/site-packages/numba/core/lowering.py:193: in lower
self.lower_normal_function(self.fndesc)
venv-3.13/lib/python3.13/site-packages/numba/core/lowering.py:232: in lower_normal_function
entry_block_tail = self.lower_function_body()
venv-3.13/lib/python3.13/site-packages/numba/core/lowering.py:262: in lower_function_body
self.lower_block(block)
venv-3.13/lib/python3.13/site-packages/numba/core/lowering.py:276: in lower_block
self.lower_inst(inst)
venv-3.13/lib/python3.13/site-packages/numba/core/lowering.py:462: in lower_inst
val = self.lower_assign(ty, inst)
venv-3.13/lib/python3.13/site-packages/numba/core/lowering.py:674: in lower_assign
return self.lower_expr(ty, value)
venv-3.13/lib/python3.13/site-packages/numba/core/lowering.py:1268: in lower_expr
res = self.lower_call(resty, expr)
venv-3.13/lib/python3.13/site-packages/numba/core/lowering.py:939: in lower_call
res = self._lower_call_normal(fnty, expr, signature)
venv-3.13/lib/python3.13/site-packages/numba/core/lowering.py:1239: in _lower_call_normal
res = impl(self.builder, argvals, self.loc)
venv-3.13/lib/python3.13/site-packages/numba/core/base.py:1190: in call
res = self._imp(self._context, builder, self._sig, args, loc=loc)
venv-3.13/lib/python3.13/site-packages/numba/core/base.py:1220: in wrapper
return fn(*args, **kwargs)
nucs/numba_helper.py:31: in codegen
sfunc.addr = builder.inttoptr(address, context.get_value_type(types.voidptr))
venv-3.13/lib/python3.13/site-packages/numba/core/cgutils.py:164: in setattr
self[self._datamodel.get_field_position(field)] = value
self = <numba.experimental.function_type.FunctionModel object at 0x104e6ee40>, field = ‘addr’
def get_field_position(self, field):
try:
return self._fields.index(field)
except ValueError:
raise KeyError("%s does not have a field named %r"
% (self.__class__.__name__, field))
E KeyError: “FunctionModel does not have a field named ‘addr’”
venv-3.13/lib/python3.13/site-packages/numba/core/datamodel/old_models.py:678: KeyError
Any help would be much appreciated !
Thanks,
Yan