Open zachjweiner opened 3 years ago
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?
Oops, that's a bug.
After 78bedd865, 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 78bedd865, like
__iadd__
and comparisons - was this intentional?cc @kaushikcfd