-
-
Notifications
You must be signed in to change notification settings - Fork 203
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
Floating point conversion in Cython wrapper. #515
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for your contribution, and quite brave that you actually dug into my unreadable generator Python mess :-) Everything looks good, but just two small requests:
- Could you also update the
CHANGELOG
file and add 3 short entries that describe the three changes that you've made? - After this is merged I'll make a new release of the python bindings, so perhaps you can also already change
version="1.3.2"
intoversion="1.4.0"
? Thanks!
Hi, Thanks for reviewing the code, happy to contribute. I have made the requested changes. There is another issue with the Best |
Thanks for making the changes, I'll merge this in.
Take your time, I'll wait till the next PR before I make a new pyclblast release. |
This pull request is related to issue #509.
There are three changes:
cl_half
. This will preserve the fp value for the calculations. I see three ways that this can be done: a) use the native opencl headercl_half.h
which provides functions for conversion, b) use the clblast machinery for converting floats to halfs or c) use the numpy core library to do the conversion. My preference is option c) and this is the one I have implemented, as it does not add extra dependencies to the module.CRLF
line endings, whichgit
picks up as changes. For convenience, the line endings have been forced to beLF
, independent of the platform.pyopencl
array class in the python implementation), likeamax
andamin
. The cython wrapper expects these arguments as floats with the same accuracy as the other vector inputs. In the C side of the code these arguments are of typesize_t
. Python users have to convert the floating point values to integers to recover the value, by for example callingnp.frombuffer(val.get().tobytes(), np.uint32)[0]
. Moreover, with the fp16 these function error out withRuntimeError: PyCLBlast: 'CLBlastXamax' failed: CLBlastInsufficientMemoryScalar: The unit-sized vector's OpenCL buffer is too small
. Changes in the generator script force these arguments to be unsigned integers with different size than the other routine inputs.This example demonstrates the changes: