【发布时间】:2021-11-17 07:29:38
【问题描述】:
我正在尝试实现 numba.jit 函数来调用 numpy.sort 函数对 numpy 数组进行排序,但它失败为“检测到从 nopython 编译路径回退到对象模式编译路径”。我的代码如下:
gg = numpy.array ([[1,0,2],[1,2,1]],dtype = np.dtype((int,int)))
@nb.jit(nb.void(numba.int32[:,:]))
def kk (gg):
np.sort(gg)
我也尝试过 njit 模式,但也出现以下错误:
"Failed in nopython mode pipeline (step: nopython frontend)
[1m[1m[1mNo implementation of function Function(<intrinsic stub>) found for signature:
>>> stub(array(int32, 2d, A))
There are 2 candidate implementations:
[1m - Of which 2 did not match due to:
Intrinsic of function 'stub': File: numba\core\overload_glue.py: Line 35.
With argument(s): '(array(int32, 2d, A))':"
我检查了 numba 文档,因为它显示支持 numpy.sort 函数。我的代码有问题吗?还是排序功能只能在对象模式下工作?
【问题讨论】: