def wrapper(func): if extending.is_jitted(func): raise TypeError( "A jit decorator was called on an already jitted function " f"{func}. If trying to access the original python " f"function, use the {func}.py_func attribute.") if not inspect.isfunction(func): raise TypeError("The decorated object is not a function (got type " f"{type(func)}).") if config.ENABLE_CUDASIM and target == 'cuda': from numba import cuda return cuda.jit(func) if config.DISABLE_JIT and not target == 'npyufunc': return func disp = dispatcher(py_func=func, locals=locals, targetoptions=targetoptions, **dispatcher_args) if cache: disp.enable_caching() if sigs is not None: # Register the Dispatcher to the type inference mechanism, # even though the decorator hasn't returned yet. from numba.core import typeinfer with typeinfer.register_dispatcher(disp): for sig in sigs: disp.compile(sig) disp.disable_compile() return disp
def _jit(func): targetoptions = kws.copy() targetoptions['debug'] = debug targetoptions['link'] = link targetoptions['opt'] = opt targetoptions['fastmath'] = fastmath targetoptions['device'] = device targetoptions['extensions'] = extensions disp = CUDADispatcher(func, targetoptions=targetoptions) if cache: disp.enable_caching() if device: from numba.core import typeinfer with typeinfer.register_dispatcher(disp): disp.compile_device(argtypes) else: disp.compile(argtypes) disp._specialized = True disp.disable_compile() return disp
def wrapper(func): if config.ENABLE_CUDASIM and target == 'cuda': from numba import cuda return cuda.jit(func) if config.DISABLE_JIT and not target == 'npyufunc': return func disp = dispatcher(py_func=func, locals=locals, targetoptions=targetoptions, **dispatcher_args) if cache: disp.enable_caching() if sigs is not None: # Register the Dispatcher to the type inference mechanism, # even though the decorator hasn't returned yet. from numba.core import typeinfer with typeinfer.register_dispatcher(disp): for sig in sigs: disp.compile(sig) disp.disable_compile() return disp