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

NumbaIRAssumptionWarning: variable 'a.1.1' is not in scope. #7623

Closed
mhostetter opened this issue Dec 6, 2021 · 3 comments
Closed

NumbaIRAssumptionWarning: variable 'a.1.1' is not in scope. #7623

mhostetter opened this issue Dec 6, 2021 · 3 comments
Labels
no action required No action was needed to resolve.

Comments

@mhostetter
Copy link

I encountered this warning (bug?) with Numba 0.54.0 and 0.54.1 in my Python package mhostetter/galois#178. A minimal reproducer is included below.

I'm not sure why the "pedantic check" is complaining, but it seems related to the lambda function and the fact the lambda arguments a and b are the same as the JIT function arguments. When the lamba arguments are renamed to aa and bb, the warnings go away.

Minimal Example

import numpy as np
print("numpy version:", np.__version__)

import numba
print("numba version:", numba.__version__)


@numba.extending.register_jitable(inline="always")
def my_xor(a, b):
    a <<= 1
    return a ^ b

x = np.array([1, 2, 3, 4, 5, 6], dtype=np.int64)
y = np.array([2, 2, 2, 2, 2, 2], dtype=np.int64)

print("Test Case 1: Default")
ufunc = numba.vectorize(["int64(int64, int64)"], nopython=True)(my_xor)
print(ufunc(x, y), "\n")

print("Test Case 2: Lambda same names")
ufunc = numba.vectorize(["int64(int64, int64)"], nopython=True)(lambda a, b: my_xor(a, b))
print(ufunc(x, y), "\n")

print("Test Case 3: Lambda different names")
ufunc = numba.vectorize(["int64(int64, int64)"], nopython=True)(lambda aa, bb: my_xor(aa, bb))
print(ufunc(x, y), "\n")

Numba 0.53.1 Output

numpy version: 1.20.3
numba version: 0.53.1
Test Case 1: Default
[ 0  6  4 10  8 14] 

Test Case 2: Lambda same names
[ 0  6  4 10  8 14] 

Test Case 3: Lambda different names
[ 0  6  4 10  8 14]

Numba 0.54.1 Output

numpy version: 1.20.3
numba version: 0.54.1
Test Case 1: Default
[ 0  6  4 10  8 14] 

Test Case 2: Lambda same names
/home/matt/.local/lib/python3.8/site-packages/numba/core/ssa.py:272: NumbaIRAssumptionWarning: variable 'a.1.1' is not in scope.

This warning came from an internal pedantic check. Please report the warning
message and traceback, along with a minimal reproducer at:
https://github.com/numba/numba/issues/new?template=bug_report.md

  warnings.warn(errors.NumbaIRAssumptionWarning(wmsg,
[ 0  6  4 10  8 14] 

Test Case 3: Lambda different names
[ 0  6  4 10  8 14]
@esc
Copy link
Member

esc commented Dec 7, 2021

on master:

 💣 zsh» python issue7623.py
numpy version: 1.20.1
numba version: 0.55.0dev0+815.g7df40d2e36
Test Case 1: Default
[ 0  6  4 10  8 14]

Test Case 2: Lambda same names
[ 0  6  4 10  8 14]

Test Case 3: Lambda different names
[ 0  6  4 10  8 14]

With 0.54.1:

 💣 zsh» python issue7623.py
numpy version: 1.20.1
numba version: 0.54.1
Test Case 1: Default
[ 0  6  4 10  8 14]

Test Case 2: Lambda same names
/Users/vhaenel/git/numba/numba/core/ssa.py:272: NumbaIRAssumptionWarning: variable 'a.1.1' is not in scope.

This warning came from an internal pedantic check. Please report the warning
message and traceback, along with a minimal reproducer at:
https://github.com/numba/numba/issues/new?template=bug_report.md

  warnings.warn(errors.NumbaIRAssumptionWarning(wmsg,
[ 0  6  4 10  8 14]

Test Case 3: Lambda different names
[ 0  6  4 10  8 14]

@mhostetter thank you reporting this. As far as I can tell, this warning is no longer raised on master. Can you double check?

@mhostetter
Copy link
Author

Yes, I can confirm current master (4469f04) does not manifest this warning.

numpy version: 1.20.3
numba version: 0.55.0dev0+877.g4469f04e0
Test Case 1: Default
[ 0  6  4 10  8 14] 

Test Case 2: Lambda same names
[ 0  6  4 10  8 14] 

Test Case 3: Lambda different names
[ 0  6  4 10  8 14]

I have a workaround for my library (changing the variable names in the lambda), but thought I'd raise it here. I wasn't sure if there should be warnings for any case, none, or all?

@esc
Copy link
Member

esc commented Dec 7, 2021

Yes, I can confirm current master (4469f04) does not manifest this warning.

numpy version: 1.20.3
numba version: 0.55.0dev0+877.g4469f04e0
Test Case 1: Default
[ 0  6  4 10  8 14] 

Test Case 2: Lambda same names
[ 0  6  4 10  8 14] 

Test Case 3: Lambda different names
[ 0  6  4 10  8 14]

I have a workaround for my library (changing the variable names in the lambda), but thought I'd raise it here. I wasn't sure if there should be warnings for any case, none, or all?

OK, thank you. I assume that there should never have been a warning and that this was probably fixed during the latest (0.55) development cycle. I will close this issue now. It should be fixed with the upcoming 0.55 (soon). Thank you again for reporting this, your help to improve Numba is appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no action required No action was needed to resolve.
Projects
None yet
Development

No branches or pull requests

3 participants