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

Regression in 0.53.0rc1 due to issue in temp variable assignment removal #6715

Closed
stuartarchibald opened this issue Feb 10, 2021 · 3 comments · Fixed by #6716
Closed

Regression in 0.53.0rc1 due to issue in temp variable assignment removal #6715

stuartarchibald opened this issue Feb 10, 2021 · 3 comments · Fixed by #6716
Assignees
Labels
bug - failure to compile Bugs: failed to compile valid code bug - regression A regression against a previous version of Numba

Comments

@stuartarchibald
Copy link
Contributor

This fails type inference on 0.53.0rc1, worked fine on 0.52.0:

from numba import njit
import numpy as np

@njit
def foo():
    increment = 0.0
    foo_sum = 0.0
    i = 2

    while foo_sum < 100:
        a = [np.random.normal(1) for _ in range(i)]
        a = np.array(a)
        increment = np.sum(a)
        increment = np.abs(increment)
        foo_sum += increment
        i += 1

    return (foo_sum, i)

foo()

Debug log:

$ cat di58.py
from numba import njit
import numpy as np

@njit
def foo():
    increment = 0.0
    foo_sum = 0.0
    i = 2

    while foo_sum < 100:
        a = [np.random.normal(1) for _ in range(i)]
        a = np.array(a)
        increment = np.sum(a)
        increment = np.abs(increment)
        foo_sum += increment
        i += 1

    return (foo_sum, i)


$ HEAD=`git rev-parse HEAD`

$ git show-ref --tags -d|grep $HEAD
90e7cc74e1c3775727289162eade941c49a0db4f refs/tags/0.53.0rc1.post1^{}

$ python di58.py
Traceback (most recent call last):
  File "di58.py", line 20, in <module>
    foo()
  <snip>
  File "/numba/core/typeinfer.py", line 1174, in check_var
    raise TypingError(msg % (var, val, loc), loc)
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Type of variable 'a' cannot be determined, operation: call $42load_method.9(a, func=$42load_method.9, args=[Var(a, di58.py:11)], kws=(), vararg=None), location: di58.py (12)

File "di58.py", line 12:
def foo():
    <source elided>
        a = [np.random.normal(1) for _ in range(i)]
        a = np.array(a)
        ^

$ git revert -m 1 d938288
[release0.53 9ddebc9] Revert "Merge pull request #6575 from ehsantn/ehsan/avoid_tmp_vars"
 11 files changed, 46 insertions(+), 179 deletions(-)

$ python di58.py # works fine

d938288 i.e. merge of #6575 seems to be the cause.

CC @ehsantn

@stuartarchibald stuartarchibald added this to the Numba 0.53.0RC2 milestone Feb 10, 2021
@stuartarchibald stuartarchibald added bug - failure to compile Bugs: failed to compile valid code bug - regression A regression against a previous version of Numba labels Feb 10, 2021
@sklam
Copy link
Member

sklam commented Feb 10, 2021

A smaller reproducer:

from numba import njit
import numpy as np

@njit
def foo():
    for i in range(3):
        a = (lambda j: j)(i)
        a = np.array(a)

    return

foo()

The temp variable assignment pass is causing the _inline_arraycall to misbehave. This can be checked by toggling

enable_inline_arraycall = True
.

@ehsantn
Copy link
Contributor

ehsantn commented Feb 11, 2021

There is probably an assumption about extra assignments somewhere. I can look at this if no one has started yet.

@sklam
Copy link
Member

sklam commented Feb 11, 2021

@ehsantn, it's all yours =)

@ehsantn ehsantn self-assigned this Feb 11, 2021
ehsantn added a commit to ehsantn/numba that referenced this issue Feb 11, 2021
sklam added a commit that referenced this issue Feb 24, 2021
Consider assignment lhs live if used in rhs (Fixes #6715)
sklam added a commit to sklam/numba that referenced this issue Feb 24, 2021
Consider assignment lhs live if used in rhs (Fixes numba#6715)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug - failure to compile Bugs: failed to compile valid code bug - regression A regression against a previous version of Numba
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants