user961627
user961627

Reputation: 12747

Remove the numba.lowering.LoweringError: Internal error

I'm using numba to speed up my code which is working fine without numba. But after using @jit, it crashes with this error:

Traceback (most recent call last):
  File "C:\work_asaaki\code\gbc_classifier_train_7.py", line 54, in <module>
    gentlebooster.train(X_train, y_train, boosting_rounds)
  File "C:\work_asaaki\code\gentleboost_c_class_jit_v7_nolimit.py", line 298, in train
    self.g_per_round, self.g = train_function(X, y, H)  
  File "C:\Anaconda\lib\site-packages\numba\dispatcher.py", line 152, in _compile_for_args
    return self.jit(sig)
  File "C:\Anaconda\lib\site-packages\numba\dispatcher.py", line 143, in jit
    return self.compile(sig, **kws)
  File "C:\Anaconda\lib\site-packages\numba\dispatcher.py", line 250, in compile
    locals=self.locals)
  File "C:\Anaconda\lib\site-packages\numba\compiler.py", line 183, in compile_bytecode
    flags.no_compile)
  File "C:\Anaconda\lib\site-packages\numba\compiler.py", line 323, in native_lowering_stage
    lower.lower()
  File "C:\Anaconda\lib\site-packages\numba\lowering.py", line 219, in lower
    self.lower_block(block)
  File "C:\Anaconda\lib\site-packages\numba\lowering.py", line 254, in lower_block
    raise LoweringError(msg, inst.loc)
numba.lowering.LoweringError: Internal error:
NotImplementedError: ('cast', <llvm.core.Instruction object at 0x000000001801D320>, slice3_type, int64)
File "gentleboost_c_class_jit_v7_nolimit.py", line 103

Line 103 is below, in a loop:

weights = np.empty([n,m])
for curr_n in range(n):
    weights[curr_n,:] = 1.0/(n) # this is line 103

where n is a constant already defined somewhere above in my code.

How can I remove the error? What "lowering" is going on? I'm using Anaconda 2.0.1 with Numba 0.13.x and Numpy 1.8.x on a 64-bit machine.

Upvotes: 4

Views: 3487

Answers (1)

user961627
user961627

Reputation: 12747

Based on this: https://gist.github.com/cc7768/bc5b8b7b9052708f0c0a,

I figured out what to do to avoid the issue. Instead of using the colon : to refer to any row/column, I just opened up the loop into two loops to explicitly refer to the indices in each dimension of the array:

weights = np.empty([n,m])
for curr_n in range(n):
    for curr_m in range (m):
        weights[curr_n,curr_m] = 1.0/(n)

There were other instances in my code after this where I used the colon, but they didn't cause errors further down, not sure why.

Upvotes: 5

Related Questions