简体   繁体   English

迭代3D数组时Numba降低错误

[英]Numba Lowering error when iterating over 3D array

I have a 3D array (n, 3,2) for holding groups of three 2D vectors and I'm iterating over them something like this: 我有一个3D数组(n,3,2)用于容纳三个2D向量的组,并且正在像这样迭代它们:

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

With normal numpy this works fine but when I wrap the function in question in a 使用普通的numpy可以正常工作,但是当我将有问题的功能包装在一个

 @numba.jit(nopython=True)

I get an error like the one below. 我收到类似下面的错误。

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

For reference the actual code is here 供参考,实际代码在这里

It looks like this is just not implemented. 看来这只是未实现。

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 "$7.2 = iternext(value=$phi7.1)" at <ipython-input-13-788b4772d1d9> (3)

Seem to works ok if you loop using the index. 如果循环使用索引,似乎可以正常工作。

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.]])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM