2

I'm trying to execute a very basic neighbour algorithm on a matrix using NumbaPro CUDA Python.

The function:

@autojit(target="gpu")    
def removeNeighboursMatCUDA(tmp_frame):
    for j in range(255):
        for i in range(255):
            if tmp_frame[i][j]!=0:
                if tmp_frame[i+1][j]!=0: 
                    tmp_frame[i][j]=0
                    tmp_frame[i][j+1]=0
                if tmp_frame[i][j+1]!=0:
                    tmp_frame[i][j]=0
                    tmp_frame[i+1][j]=0
                if tmp_frame[i+1][j+1]!=0:
                    tmp_frame[i][j]=0
                    tmp_frame[i+1][j+1]=0
                if i>0 and tmp_frame[i-1][j-1]!=0:
                    tmp_frame[i][j]=0
                    tmp_frame[i-1][j-1]=0
    return tmp_frame

The functions input is a 2D array (256x256):

tmp_frame = coo_matrix((c_tmp,(x_tmp,y_tmp)),shape=(256,256)).todense()
M = removeNeighboursMatCUDA(tmp_frame)

This code executes without any problems when the target is the CPU, but for the GPU I get the following error:

TypingError: No conversion from array(int16, 2d, C) to none for '$333.2'

I cannot find anything about this error. Anyone knows what is wrong or what the problem could be?

EDIT: The error is caused by the return statement. Removing the return fixes the code.

tillúr
  • 93
  • 8

1 Answers1

3

I found it out myself. As already stated in the EDIT, the problem is the return statement. The fixed code is attached below:

@jit(target="gpu")  
def removeNeighboursMatCUDA(tmp_frame,res_frame):
    for j in range(255):
        for i in range(255):
            if tmp_frame[i][j]!=0:
                if tmp_frame[i+1][j]!=0: 
                    res_frame[i][j]=0
                    res_frame[i][j+1]=0
                if tmp_frame[i][j+1]!=0:
                    res_frame[i][j]=0
                    res_frame[i+1][j]=0
                if tmp_frame[i+1][j+1]!=0:
                    res_frame[i][j]=0
                    res_frame[i+1][j+1]=0
                if i>0 and tmp_frame[i-1][j-1]!=0:
                    res_frame[i][j]=0
                    res_frame[i-1][j-1]=0
    tmp_frame=res_frame
tillúr
  • 93
  • 8