0
Recently, I decided to practice using numba on numpy scripts, but suddenly, numba now refuses to work with a numpy only section of my script. First, I thought that the numba was throwing errors becuase I had non-numpy areas of my code in the function which I used the vectorize operator on, but after creating a new function, with only numpy arguments and code, I still get more errors. Here is the section of the code that I am attempting to vectorize
@vectorize([float64(float64, float64, float64, float64, float64, float64)], target='cuda')
def np_filter(k, idx, epsilon, points, points_copy, i):
neighbors = points[idx, :]
mean = np.mean(neighbors)
cov = np.cov(neighbors.T)
e = np.linalg.inv(cov + epsilon * np.eye(3))
A = cov @ e
b = mean - A @ mean
points_copy[i] = A @ points[i] + b
return points_copy
I used float64 as both input and output argument dytype values, since I want them both to be in float 64. When I try the code with the target=‘cuda’ flag, I get these errors.
getitem(float64, Tuple(float64, slice<a:b>))
There are 16 candidate implementations:
[1m - Of which 16 did not match due to:
Overload of function 'getitem': File: <numerous>: Line N/A.
With argument(s): '(float64, Tuple(float64, slice<a:b>))':[0m
[1m No match.[0m
I thought this might be due to the fact that the numpy function which I called might not have the ability to be parallelize, so I removed the cuda flag, and got new errors.
File "main.py", line 61, in <module>
main()
File "main.py", line 14, in main
pcd = guided_filter(pcd, 0.01, 0.25)
File "main.py", line 43, in guided_filter
points_copy = np_filter(k, idx, epsilon, points, points_copy, i)
ValueError: operands could not be broadcast together with shapes () (114,) () (35947,3) (35947,3) ()
Could someone please help me resolve these errors? I’ve been having a hard time understand what might be causing this issues, and for me, even the pure numpy function in the filter functions can not be optimized, so I’m unsure about how to fix my program.