pycuda
pycuda copied to clipboard
`GPUArray.__div__` does not comply with numpy
Here's an MWE:
>>> import pycuda.autoinit
>>> import pycuda.gpuarray as cu_np
>>> a = cu_np.zeros(10, dtype="int32") + 1
>>> b = cu_np.zeros(10, dtype="int32") + 2
>>> a / b
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], dtype=int32)
while, Numpy returns an array of 0.5's
>>> import numpy as np
>>> a = np.zeros(10, "int32") + 1
>>> b = np.zeros(10, "int32") + 2
>>> a / b
array([0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5])
That's clearly a bug. Believe it or not, PyCUDA predates __truediv__, I think. :astonished:
There's a proposed fix for this at https://gitlab.tiker.net/inducer/pycuda/-/merge_requests/66.