pycuda icon indicating copy to clipboard operation
pycuda copied to clipboard

binary operations make a bool array

Open brumen opened this issue 4 years ago • 7 comments

I feel binary operations should make a bool GPUarray, not the same as before.

brumen avatar Mar 12 '21 19:03 brumen

I feel like you might be misunderstanding something here... "binary" operator refers to "having two operands", i.e. "a+b". A unary operator is one with one operand, e.g. "-a".

inducer avatar Mar 12 '21 20:03 inducer

Sorry, I wasn't precise enough - the function _make_binary_op is used only for comparison operators in gpuarray.py, (<, == , etc.) Shouldn't the output of that operation be a bool array?

brumen avatar Mar 12 '21 20:03 brumen

Gitlab sister MR for CI: https://gitlab.tiker.net/inducer/pycuda/-/merge_requests/47

inducer avatar Mar 13 '21 00:03 inducer

One more question (i dont know if this is the relevant medium): Have you considered implementing GPUArrays for object dtypes? At least for example for subclasses of Enum?

brumen avatar Mar 14 '21 15:03 brumen

In general, make new issues for separate topics. (Spoiler alert: object arrays aren't happening. They're tied to the Python runtime, which doesn't exist on the GPU. Enums are more likely, but only if you can find a way to map them into the numpy type system.)

inducer avatar Mar 14 '21 19:03 inducer

Instead of hardcoding a bool return type to the (previously general) _make_binary_op, add an optional force_return_dtype=None argument.

inducer avatar Mar 14 '21 19:03 inducer

Sure, I'll make another pull request tomorrow.

brumen avatar Mar 14 '21 20:03 brumen