@guvectorize does not return values for multiple variables

I am trying to parallelize a function using the @guvectorize decorator. The function takes multiple inputs and should generate multiple outputs of which each has a different shape. My code (reproduced in part below) runs without any errors, yet, the values of the second output parameter are not returned to the location where I call the vectorized function.

My question is:

  • How do I get the function rotate_GPU to return the values of rot_data and rot_or and not only the values of rot_data as it does currently?
dat, rot = rotate_GPU(dat, rot, dtheta)

@guvectorize(['(float64[:,:], float64[:], float64, float64[:,:],float64[:])'], 
             '(n,m),(p),()->(n,m),(p)', nopython=True, target="parallel")
def rotate_GPU(data, orientation, dtheta, rot_data, rot_or):
      # Several calculations taking data, orientation, dtheta in which I
      # assign values to rot_data and rot_or. I have made sure that the 
      # dimensions of these variables agree with the signature, so that
      # data.shape = (n,m)
      # orientation.shape = (p)
      # dtheta.shape = ()
      # rot_data.shape = (n,m)
      # rot_or.shape = (p)

Could you please post an executable version of the code that reproduces the issue? It should be a bit easier to work out what the problem is if the issue can be reproduced.

I did not manage to reproduce the issue in a simplified, executable version of my code, and the function decorator turned out to be perfectly valid. Instead, I made a stupid mistake in an another part of the code, so the issue was unrelated to numba. I was unsure whether the @guvectorize could handle the in- and output structure that I wanted, and at first sight the problem appeared to be related to the section of the code calling the decorate function.

However, your suggestion to post an executable version forced me to go through the code line by line with the knowledge that the mistake was probably elsewhere, since you did not question the validity of the decorator statement. The issue turned out to be a simple typo in a variable name :man_facepalming:

What I learned for next time:

  • Try to make a minimal example that reproduces the behavior before posting because this will either: 1) expose the issue or 2) help others expose the issue if you don’t manage by yourself.
1 Like