Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

register_jitable -ed function not recognized when used as arg to njit function #7043

Open
2 tasks done
LunarLanding opened this issue May 19, 2021 · 0 comments
Open
2 tasks done

Comments

@LunarLanding
Copy link
Contributor

Reporting a bug

register_jitable-ed function is not recognized when used as arg to njit-ed function.

Numba version: 0.53.1
Code:

import numba as nb
import numba.extending

@nb.extending.register_jitable
def g(x):
    return 2*x

@nb.njit
def f(g,x):
    x+=1
    return g(x)

f(g,2)
---------------------------------------------------------------------------
TypingError                               Traceback (most recent call last)
<ipython-input-1-cbb9b70cf0f8> in <module>
     11     return g(x)
     12 
---> 13 f(g,2)

~/miniconda3/lib/python3.9/site-packages/numba/core/dispatcher.py in _compile_for_args(self, *args, **kws)
    418                 e.patch_message(msg)
    419 
--> 420             error_rewrite(e, 'typing')
    421         except errors.UnsupportedError as e:
    422             # Something unsupported is present in the user code, add help info

~/miniconda3/lib/python3.9/site-packages/numba/core/dispatcher.py in error_rewrite(e, issue_type)
    359                 raise e
    360             else:
--> 361                 raise e.with_traceback(None)
    362 
    363         argtypes = []

TypingError: Failed in nopython mode pipeline (step: nopython frontend)
non-precise type pyobject
During: typing of argument at <ipython-input-1-cbb9b70cf0f8> (10)

File "<ipython-input-1-cbb9b70cf0f8>", line 10:
def f(g,x):
    x+=1
    ^

This error may have been caused by the following argument(s):
- argument 0: Cannot determine Numba type of <class 'function'>
  • I have tried using the latest released version of Numba (most recent is
    visible in the change log (https://github.com/numba/numba/blob/master/CHANGE_LOG).
  • I have included a self contained code sample to reproduce the problem.
    i.e. it's possible to run as 'python bug.py'.

Swaping register_jitable for njit works:

import numba as nb
import numba.extending

# @nb.extending.register_jitable
@nb.njit
def g(x):
    return 2*x

@nb.njit
def f(g,x):
    x+=1
    return g(x)

f(g,2)
6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants