Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPUArray.__div__ does not comply with numpy #360

Open
kaushikcfd opened this issue Jun 30, 2022 · 2 comments
Open

GPUArray.__div__ does not comply with numpy #360

kaushikcfd opened this issue Jun 30, 2022 · 2 comments
Labels

Comments

@kaushikcfd
Copy link
Contributor

kaushikcfd commented Jun 30, 2022

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])
@kaushikcfd kaushikcfd added the bug label Jun 30, 2022
@inducer
Copy link
Owner

inducer commented Jun 30, 2022

That's clearly a bug. Believe it or not, PyCUDA predates __truediv__, I think. 😲

@kaushikcfd
Copy link
Contributor Author

There's a proposed fix for this at https://gitlab.tiker.net/inducer/pycuda/-/merge_requests/66.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants