遍历 3D 数组时 Numba 降低错误

Numba Lowering error when iterating over 3D array

我有一个 3D 数组 (n, 3,2) 用于保存三个 2D 向量组,我正在像这样迭代它们:

import numpy as np
for x in np.zeros((n,2,3), dtype=np.float64):
     print(x) # for example

对于普通的 numpy 这工作正常但是当我将有问题的函数包装在

 @numba.jit(nopython=True)

我收到如下错误。

numba.errors.LoweringError: Failed at nopython (nopython mode backend)
iterating over 3D array
File "paint.py", line 111
[1] During: lowering ".2 = iternext(value=$phi77.1)" at paint.py (111)

参考实际代码是here

看起来这只是没有实现。

In [13]: @numba.njit
    ...: def f(v):
    ...:     for x in v:
    ...:         y = x
    ...:     return y

In [14]: f(np.zeros((2,2,2)))
NotImplementedError                       Traceback (most recent call last)
<snip>
LoweringError: Failed at nopython (nopython mode backend)
iterating over 3D array
File "<ipython-input-13-788b4772d1d9>", line 3
[1] During: lowering ".2 = iternext(value=$phi7.1)" at <ipython-input-13-788b4772d1d9> (3)

如果你循环使用索引,似乎工作正常。

In [15]: @numba.njit
    ...: def f(v):
    ...:     for i in range(len(v)):
    ...:         y = v[i]
    ...:     return y

In [16]: f(np.zeros((2,2,2)))
Out[16]: 
array([[ 0.,  0.],
       [ 0.,  0.]])