inducer / pyopencl

OpenCL integration for Python, plus shiny features
http://mathema.tician.de/software/pyopencl
Other
1.04k stars 238 forks source link

Fix buffer size computation #660

Closed pierrepaleo closed 1 year ago

pierrepaleo commented 1 year ago

Fix #659

pierrepaleo commented 1 year ago

Thanks, a comment was added and the individual components are checked.

numpy.prod(shape) can still yield floating-point values, for example when shape = (1, np.uint64(2), 4). So the product is computed on values cast to uint64, but not sure that's a good idea. Perhaps each component should be checked to be an int (and raise an error if a float is found).

Any thoughts ?

inducer commented 1 year ago

numpy.prod lets you specify the output dtype:

https://numpy.org/doc/stable/reference/generated/numpy.prod.html#numpy.prod

inducer commented 1 year ago

Pushed some minor fixes. This looks good to me now. Thanks for your contribution!