Traceback (most recent call last):
File "test_numba.py", line 33, in <module>
print(foo(baz, 2))
File "<snip>\Python38\lib\site-packages\numba\core\dispatcher.py", line 656, in _explain_matching_error
raise TypeError(msg)
TypeError: No matching definition for argument type(s) type(CPUDispatcher(<function baz at 0x000001DFA8C2D1F0>)), int64
我也在寻找解决办法。不幸的是,@Carbon的建议不起作用,因为函数
bar
的numba.typeof
返回的类型与函数baz
的类型不同,即使bar
和baz
的签名相同例如:
foo(bar, 2)
返回4foo(baz, 2)
返回以下异常:我发现的唯一解决办法是完全省略
foo
的函数签名,让numba来解决这个问题。我不知道这会给你的代码带来什么负面影响(如果有的话)例如:
foo(bar, 2)
返回4foo(baz, 2)
返回6所以,我不知道如何生成你要寻找的签名,但是如果你有一个带有你要签名的编译函数的样本,你可以使用^ {CD1>}得到预期的签名,考虑,例如:
我查过了,这真是太好了。如果您想进一步处理这个问题,正确的开始位置是
numba.core.types.functions
,并且Dispatcher
类型是在编译中专门处理的,请参见numba.core.typing.context.BaseContext
的._resolve_user_function_type
我也对这一点感到好奇,因为我也想对runge-kutta四阶算法进行急切的编译。我还认真地搜索了文档,不幸的是,这似乎还没有实现:(因此,我们现在唯一要做的就是让它进行惰性编译,并在第一次函数调用时体验编译
相关问题 更多 >
编程相关推荐