Numba: Fall-back from the nopython compilation path to the object mode compilation path has been detected

Viewed 1020

I am trying to compile python function with numba @jit. In the argument list, N1,N2,N3 are integers, FX,FY,FZ are numpy matrices with float64 data type,inx,...,ground is numpy array with int64 datatype, and inb,res has int64 data type. In below function, spdiags, lil_matrix,csx_matrix are from scipy.sparse library.

@jit
def ThreeDChannel_Differentiate1(N1,N2,N3,FX,FY,FZ,
                                 inx,iny,inz,A0,AN,AS,AE,AW,AA,AG,east,
                                 west,north,south,air,ground,inb,res):

    data = np.zeros((7,(N1*N2*(N3-2))))
    diags = np.array([-N1*(N3-2), -N1, -1, 0, 1, N1, N1*(N3-2)])
    M = spdiags(data, diags, N1*N2*(N3-2), N1*N2*(N3-2))
    #M = sp.csc_matrix(M)
    M = sp.lil_matrix(M)

    for k in inz-1:
        for j in inx:
            for i in iny:
                FY0 = FY[i,j,k+1]
                FYN = FY[north[i],j,k+1]
                FYS = FY[south[i],j,k+1]

                FX0 = FX[i,j,k+1]
                FXE = FX[i,east[j],k+1]
                FXW = FX[i,west[j],k+1]

                FZ0 = FZ[i,j,k+1]
                FZA = FZ[i,j,air[k]]
                FZG = FZ[i,j,ground[k]]

                if inb == 1:
                    M[A0[i,j,k],A0[i,j,k]] = 1/FY0*(FYN/(FY0+FYN)-FYS/(FYS+FY0))

                if inb == 2:
                    M[A0[i,j,k],A0[i,j,k]] = 1/FX0*(FXE/(FX0+FXE)-FXW/(FXW+FX0))

                if inb == 3:
                    M[A0[i,j,k],A0[i,j,k]] = 1/FZ0*(FZA/(FZ0+FZA)-FZG/(FZG+FZ0))

                if inb == 1:
                    M[A0[i,j,k],AN.ravel(order='F')[A0[i,j,k]]] = 1/FY0*FY0/(FY0+FYN)
                    M[A0[i,j,k],AS.ravel(order='F')[A0[i,j,k]]] = -1/FY0*FY0/(FY0+FYS)

                if inb == 2:
                    M[A0[i,j,k],AE.ravel(order='F')[A0[i,j,k]]] = 1/FX0*FX0/(FX0+FXE)
                    M[A0[i,j,k],AW.ravel(order='F')[A0[i,j,k]]] = -1/FX0*FX0/(FX0+FXW)

                # Account for wall Dirichlet (no-slip) condition in the wall-normal direction
                if inb == 3:
                    if AG.ravel(order='F')[A0[i,j,k]] >= 0:
                        M[A0[i,j,k],AG.ravel(order='F')[A0[i,j,k]]] = -1/FZ0*FZ0/(FZ0+FZG)
                    else:
                        M[A0[i,j,k],A0[i,j,k]] = 1/FZ0*(FZA/(FZ0+FZA)-FZG/(FZG+FZ0) + \
                                                 FZ0/(FZG+FZ0))

                    if AA.ravel(order='F')[A0[i,j,k]] < N1*N2*(N3-2):
                        M[A0[i,j,k],AA.ravel(order='F')[A0[i,j,k]]] = 1/FZ0*FZ0/(FZ0+FZA)

                    else:
                        M[A0[i,j,k],A0[i,j,k]] = 1/FZ0*(FZA/(FZ0+FZA)-FZG/(FZG+FZ0) - \
                                                 FZ0/(FZA+FZ0))

    M = sp.csc_matrix(M, copy=False)

    return M

If I call the above function, I get below error. Also, I get a warning related to spdiag object. I think scipy objects are not supported by Numba. But the below warning is related to the for loop. What is this error related to?

File "<ipython-input-5-66816b729db2>", line 13:
def ThreeDChannel_Differentiate1(N1,N2,N3,FX,FY,FZ,
    <source elided>

    for k in inz-1:
    ^

  self.func_ir.loc))
/home/suraj/anaconda3/lib/python3.7/site-packages/numba/compiler.py:734: NumbaDeprecationWarning: 
Fall-back from the nopython compilation path to the object mode compilation path has been detected, this is deprecated behaviour.

Thank you.

0 Answers
Related