【问题标题】:Numba nested function won't execute (version 0.47)Numba 嵌套函数不会执行(0.47 版)
【发布时间】:2020-01-20 06:26:05
【问题描述】:

我很困惑为什么这不起作用,文档说:

2.6.1.2.3。内部函数和闭包: Numba 现在支持内部函数,只要它们是非递归的并且仅在本地调用,但不作为参数传递或作为结果返回。闭包变量(在外部范围中定义的变量)的使用 也支持内部函数。

import numba

@numba.jit(nopython=True, debug=False, parallel=False, cache=True)
def outer() -> int:

    @numba.jit(nopython=True, debug=False, parallel=False, cache=True)
    def inner() -> int:
        return 1

    return inner()

outer()

还有错误:

Failed in nopython mode pipeline (step: analyzing bytecode)
op_MAKE_FUNCTION with annotations is not implemented

我在这里做了什么傻事吗?

(操作系统:Ubuntu 19.10)

【问题讨论】:

  • 您是否在刻意测试numba 是否支持类型提示?如果没有,删除-> int 可能会解决您的问题。如果是这样,这可能是一个错误,除非真正了解 numba 的人说不是,否则我建议您 report it by filing an issue in the github repository 或采取类似行动。
  • 我试过了(删除类型提示),它不起作用

标签: python numba


【解决方案1】:

Soln:不要使用类型声明并移除内部 j​​it 装饰器

【讨论】:

    猜你喜欢
    • 2018-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-10
    相关资源
    最近更新 更多