Saturday, 9 September 2023

Numba Dispatch error when Number of keyword args > 3 for nested numba calls

This error happens when defining function * is used. I can start with three function definition cases, The first two cases are passed, and the third one which is a minor modification of the second test case fails. Maybe * are not supported however the error is interesting would like to understand the cause.

Numba version: '0.56.4' Python version: '3.9.17'

Pass Test 1

import numba as nb
def test_1(a, b, c, d, e, f, g):
    return a + b + c + d + e + f + g
test_1 = nb.njit(test_1)

def test_2(a, b, c, d, e, f, g):
    return test_1(a, b, c, d, e, f, g)
test_2 = nb.njit(test_2)
test_2(1, 2, 3, 4, 5, 6, 7)

Pass Test 2

import numba as nb
def test_1(a, b, c, *, d, e, f):
    return a + b + c + d + e + f
test_1 = nb.njit(test_1)

def test_2(a, b, c, d, e, f, g):
    return test_1(a, b, c, d, e, f)
test_2 = nb.njit(test_2)
test_2(1, 2, 3, 4, 5, 6, 7)

Fail Test 3

import numba as nb
def test_1(a, b, c, *, d, e, f, g):
    return a + b + c + d + e + f
test_1 = nb.njit(test_1)

def test_2(a, b, c, d, e, f, g):
    return test_1(a, b, c, d, e, f, g)
test_2 = nb.njit(test_2)
test_2(1, 2, 3, 4, 5, 6, 7)

Error traceback

---------------------------------------------------------------------------
TypingError                               Traceback (most recent call last)
Cell In[10], line 9
      7 test_2 = nb.njit(test_2)
      8 # test_1(1, 2, 3, 4, 5, 6, 7)
----> 9 test_2(1, 2, 3, 4, 5, 6, 7)

File ~/.cache/pypoetry/virtualenvs/indices-ldm-post-process-danSbNDA-py3.9/lib/python3.9/site-packages/numba/core/dispatcher.py:467, in _DispatcherBase._compile_for_args(self, *args, **kws)
    464         msg = (f"{str(e).rstrip()} \n\nThis error may have been caused "
    465                f"by the following argument(s):\n{args_str}\n")
    466         e.patch_message(msg)
--> 467     error_rewrite(e, 'typing')
    468 except errors.UnsupportedError as e:
    469     # Something unsupported is present in the user code, add help info
    470     error_rewrite(e, 'unsupported_error')

File ~/.cache/pypoetry/virtualenvs/indices-ldm-post-process-danSbNDA-py3.9/lib/python3.9/site-packages/numba/core/dispatcher.py:409, in _DispatcherBase._compile_for_args..error_rewrite(e, issue_type)
    407     raise e
    408 else:
--> 409     raise e.with_traceback(None)

TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Internal error at .
tuple index out of range
During: resolving callee type: type(CPUDispatcher())
During: typing of call at /tmp/ipykernel_3435313/3644502072.py (6)

Enable logging at debug level for details.

I have raised an issue at Numba github



from Numba Dispatch error when Number of keyword args > 3 for nested numba calls

No comments:

Post a Comment