IntelLabs / numba

NumPy aware dynamic Python compiler using LLVM
http://numba.pydata.org/
BSD 2-Clause "Simplified" License
12 stars 2 forks source link

Core-pa Slice Error #43

Closed ehsantn closed 6 years ago

ehsantn commented 6 years ago

This code fails in the core-pa branch (undefined variable).

import numba
import numpy as np

@numba.njit(parallel=True)
def f(n):
    A = np.ones(n)
    w = 5
    A[:w//2] = 2.0
    return A

print(f(10))
  File "/Users/etotoni/pse-hpc/python/numba/numba/errors.py", line 259, in new_error_context
    yield
  File "/Users/etotoni/pse-hpc/python/numba/numba/lowering.py", line 216, in lower_block
    self.lower_inst(inst)
  File "/Users/etotoni/pse-hpc/python/numba/numba/lowering.py", line 265, in lower_inst
    val = self.lower_assign(ty, inst)
  File "/Users/etotoni/pse-hpc/python/numba/numba/lowering.py", line 411, in lower_assign
    return self.lower_expr(ty, value)
  File "/Users/etotoni/pse-hpc/python/numba/numba/lowering.py", line 712, in lower_expr
    return self.lower_binop(resty, expr, expr.fn)
  File "/Users/etotoni/pse-hpc/python/numba/numba/lowering.py", line 469, in lower_binop
    rhs = self.loadvar(rhs.name)
  File "/Users/etotoni/pse-hpc/python/numba/numba/lowering.py", line 920, in loadvar
    ptr = self.getvar(name)
  File "/Users/etotoni/pse-hpc/python/numba/numba/lowering.py", line 914, in getvar
    return self.varmap[name]
numba.errors.LoweringError: Failed at nopython (nopython mode backend)
'$18'
File "tmp_tests/slice_test.py", line 8
[1] During: lowering "$19 = $0.11 - $18" at tmp_tests/slice_test.py (8)
ninegua commented 6 years ago

Should be fixed by a38aeacb

ehsantn commented 6 years ago

A slightly different one still fails:

import numba
import numpy as np

@numba.njit(parallel=True)
def f(n):
    A = np.ones(n)
    w = 5
    A[-(w//2):] = 2.0
    return A

print(f(10))
ninegua commented 6 years ago

Good catch! Fixed now.

ehsantn commented 6 years ago

Everything works now. Thanks!