You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Namely, pyopencl.Array.__add__ returns NotImplemented in this case and so python then asks the numpy array what to do. It appears numpy chooses to loop over each scalar element of the CL array and call its __add__ method, and for some reason converts the unit-sized array into a scalar (which is why the single-element additions don't fail).
Could the np.isscalar(other) check be replaced (or augmented with) other.size == 1, perhaps?
Also, a few binary ops were missed in 78bedd8, like __iadd__ and comparisons - was this intentional?
Could the np.isscalar(other) check be replaced (or augmented with) other.size == 1, perhaps?
Replacing or augmenting with other.size == 1 might not be the correct behavior as the resulting array's shape might not follow numpy's broadcasting semantics. (I'm also unsure what's the correct behavior here)
Also, a few binary ops were missed in 78bedd8, like iadd and comparisons - was this intentional?
After 78bedd8, binary operations between a unit-sized numpy array and a PyOpenCL array ends up looping over each element of the CL array.
Namely,
pyopencl.Array.__add__
returnsNotImplemented
in this case and so python then asks the numpy array what to do. It appears numpy chooses to loop over each scalar element of the CL array and call its__add__
method, and for some reason converts the unit-sized array into a scalar (which is why the single-element additions don't fail).Could the
np.isscalar(other)
check be replaced (or augmented with)other.size == 1
, perhaps?Also, a few binary ops were missed in 78bedd8, like
__iadd__
and comparisons - was this intentional?cc @kaushikcfd
The text was updated successfully, but these errors were encountered: