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

numba jit: "Type of variable <varname>.2 cannot be determined" for a fully specified variable. #128548

Closed
dakra137 opened this issue Jan 6, 2025 · 1 comment

Comments

@dakra137
Copy link

dakra137 commented Jan 6, 2025

Bug report

Bug description:

I have several functions that work fine with jit and njit. All variables are explicitly typed, such as

def afun(parm1:int, parm2:int)->list[int]:
   varname:int=3
   listname:list[int]=[0]

In one function, the jit complains about a variable as having an undeterminable type, even though it has been explicitly typed:
Type of variable 'artp.2' cannot be determined, operation: call $1078load_global.2($binop_add1104.10, func=$1078load_global.2, args=[Var($binop_add1104.10, primes2025a.py:240)], kws=(), vararg=None, varkwarg=None, target=None), location: /home/dakra/./primes2025a.py (240)

where the code looks like:

from numba import njit
from numba import jit

@jit 
def sieve12(upToNumm: int=100000000, pnprimorial:int=3) -> list[int]:
#  early in the function similar to:
    C0:int=0
    modprimorialdo:list[int]=[1,5]
    lmodprimorialdo:int=len(modprimorialdo)
    ddocol:int=C0
    fdorowcol:list[int]=[C0,C0]
    artp:int=C0

# and later:  
   # there are assignment statements for useful values for these variables, and then:
    artp:int=int(ddocol+fdorowcol[C0]*lmodprimorialdo))

The full error report is :

Traceback (most recent call last):
  File "/home/dakra/./primes2025a.py", line 810, in <module>
    print("sieve12",n,pr,len(primesl:=sieve12(n,pr)), primesl[:10], primesl[-10:])
                                      ^^^^^^^^^^^^^
  File "/home/dakra/.local/lib/python3.12/site-packages/numba/core/dispatcher.py", line 423, in _compile_for_args
    error_rewrite(e, 'typing')
  File "/home/dakra/.local/lib/python3.12/site-packages/numba/core/dispatcher.py", line 364, in error_rewrite
    raise e.with_traceback(None)
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Type of variable 'artp.2' cannot be determined, operation: call $1078load_global.2($binop_add1104.10, func=$1078load_global.2, args=[Var($binop_add1104.10, primes2025a.py:240)], kws=(), vararg=None, varkwarg=None, target=None), location: /home/dakra/./primes2025a.py (240)

File "primes2025a.py", line 240:
def sieve12(upToNumm: int=100000000, pnprimorial:int=3)->list[int]: 
    <source elided>

           artp:int=int(ddocol+fdorowcol[C0]*lmodprimorialdo)
           ^

In another case, the jit processing complained about one of the parameters.
What does it take to get the jit to recognize the explicit type specifications?

CPython versions tested on:

3.12

Operating systems tested on:

Linux

@dakra137 dakra137 added the type-bug An unexpected behavior, bug, or error label Jan 6, 2025
@Eclips4
Copy link
Member

Eclips4 commented Jan 6, 2025

Hi!
This repository is a CPython bug tracker, and numba is not part of CPython.
Please report it to the Numba bug tracker: https://github.com/numba/numba/issues

@Eclips4 Eclips4 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 6, 2025
@Eclips4 Eclips4 removed the type-bug An unexpected behavior, bug, or error label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants