一旦调用jitted函数,numba就会失败

时间:2018-01-18 20:53:58

标签: python function optimization jit numba

我正在编写一些代码来“平滑”#39; a .fits图像,虽然效果很好,但速度相当慢(每张图像约3分钟)。我正在尝试使用numba来优化代码,但是我试图让它与我调用的函数一起工作。我认为这个问题与numba将变量从一个块传递到另一个块的方式有关。

功能更顺畅'从指定的文件夹中获取一个.fits文件并将其(作为一个数组)输入到“pixcal”中。功能。 ' pixcal'将图像转换成堆栈(即1024x32x32阵列),然后“pixcal”'把它喂入“车厢”中。功能。 '矩形波串'迭代整个图像并将堆栈输入“robust_mean”#39;它实际平滑,然后平滑的数组返回到开头。这是pastebin:https://pastebin.com/CwDbN5D3

在执行任何一个jitted函数之前,即使执行一行,代码也会失败。有没有人知道这里出了什么问题?

这是一条错误消息:

Analyzing file 1 of 5: image_contracted_R01_M01_N02.fits
begin pixcals and smoothing (may take a while)
size of image:  (1024, 1024)
made stack:  (1024, 32, 32)
boxcar smoothing
Traceback (most recent call last):

  File "<ipython-input-29-93e136cc4875>", line 1, in <module>
    runfile('C:/Users', wdir='C:/Users')

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 710, in runfile
    execfile(filename, namespace)

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 101, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/Documents/AAA_Lab_Work/Python/smoothing/good_code/combined code.py", line 197, in <module>
    smoother()

  File "C:/Users/Documents/AAA_Lab_Work/Python/smoothing/good_code/combined code.py", line 186, in smoother
    hdu = fits.PrimaryHDU(pixcal(fits.getdata(filename), width, channels)) #create hdu object to encapsulate data

  File "C:\ProgramData\Anaconda3\lib\site-packages\numba\dispatcher.py", line 307, in _compile_for_args
    return self.compile(tuple(argtypes))

  File "C:\ProgramData\Anaconda3\lib\site-packages\numba\dispatcher.py", line 579, in compile
    cres = self._compiler.compile(args, return_type)

  File "C:\ProgramData\Anaconda3\lib\site-packages\numba\dispatcher.py", line 80, in compile
    flags=flags, locals=self.locals)

  File "C:\ProgramData\Anaconda3\lib\site-packages\numba\compiler.py", line 766, in compile_extra
    return pipeline.compile_extra(func)

  File "C:\ProgramData\Anaconda3\lib\site-packages\numba\compiler.py", line 362, in compile_extra
    return self._compile_bytecode()

  File "C:\ProgramData\Anaconda3\lib\site-packages\numba\compiler.py", line 725, in _compile_bytecode
    return self._compile_core()

  File "C:\ProgramData\Anaconda3\lib\site-packages\numba\compiler.py", line 712, in _compile_core
    res = pm.run(self.status)

  File "C:\ProgramData\Anaconda3\lib\site-packages\numba\compiler.py", line 248, in run
    raise patched_exception

  File "C:\ProgramData\Anaconda3\lib\site-packages\numba\compiler.py", line 240, in run
    stage()

  File "C:\ProgramData\Anaconda3\lib\site-packages\numba\compiler.py", line 433, in stage_objectmode_frontend
    cres = self.frontend_looplift()

  File "C:\ProgramData\Anaconda3\lib\site-packages\numba\compiler.py", line 413, in frontend_looplift
    flags=loop_flags)

  File "C:\ProgramData\Anaconda3\lib\site-packages\numba\transforms.py", line 193, in loop_lifting
    cfg = compute_cfg_from_blocks(blocks)

  File "C:\ProgramData\Anaconda3\lib\site-packages\numba\analysis.py", line 213, in compute_cfg_from_blocks
    cfg.add_edge(k, target)

  File "C:\ProgramData\Anaconda3\lib\site-packages\numba\controlflow.py", line 83, in add_edge
    assert dest in self._nodes

AssertionError: Failed at object (object mode frontend)

非常感谢您的帮助:^)

0 个答案:

没有答案