Numba无法编译出非常奇怪的消息-好像这样应该可以工作吗? [英] Numba failing to compile with very strange message - seems like this should work?

查看:167
本文介绍了Numba无法编译出非常奇怪的消息-好像这样应该可以工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的函数,无法使用Numba的@njit装饰器进行编译:

I have a simple function that is failing to compile with Numba's @njit decorator:

@njit(fastmath=True, nogil=True)
def insert_into_array(array, pos, array_to_insert):
    start = array[0:pos]
    end = array[pos:len(array)]
    inserted = np.concatenate((start, array_to_insert))
    return np.concatenate(inserted, end)

此消息失败:

Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function(<function concatenate at 0x000001E88B04E8B0>) with argument(s) of type(s): (array(uint8, 1d, C), array(uint8, 1d, C))
 * parameterized
In definition 0:
    All templates rejected with literals.
In definition 1:
    All templates rejected without literals.
This error is usually caused by passing an argument of a type that is unsupported by the named function.
[1] During: resolving callee type: Function(<function concatenate at 0x000001E88B04E8B0>)

请注意,失败的类型是(array(uint8, 1d, C), array(uint8, 1d, C))-基本上是尝试连接两个简单的1d数组.

Note that the types failing on are (array(uint8, 1d, C), array(uint8, 1d, C)) - basically trying to concatenate two simple 1d arrays.

由于NumPy的concatenate函数被Numba列为受支持的函数,因此我在解决该问题时应该做些麻烦.

I'm having a lot of trouble understanding what should I do to fix this since NumPy's concatenate function is listed as a supported function by Numba.

我使用的是Python 3.7和Numba 0.50

I'm on Python 3.7 and Numba 0.50

关于我在做什么错的任何想法?

Any ideas on what am I doing wrong?

谢谢!

推荐答案

这看起来像一个函数,从一开始就被麻木完全没有任何好处.无论如何,np.concatenate的第一个参数应该是一个元组,您不能传递var args.您的最后一个通话正在尝试.

This looks like a function which does not benefit at all from being numba'd in the first place. Anyway, the first argument to np.concatenate should be a tuple, you cannot pass var args. Your last call is trying that.

这篇关于Numba无法编译出非常奇怪的消息-好像这样应该可以工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆