inducer / pyopencl

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

Reduction algorithms on Image objects #290

Open eithun opened 5 years ago

eithun commented 5 years ago

How can I perform a reduction on an Image object? The module (https://documen.tician.de/pyopencl/algorithm.html?highlight=reduction#pyopencl.reduction.ReductionKernel) seems to only support arrays being passed to kernel function.

inducer commented 5 years ago

There's not currently code to do that, but I'd be happy to consider a patch if it's sufficiently clean. A particular problem is that images are often 2D.

eithun commented 5 years ago

Yes, this functionally would be great! I'd like to do "image things" but also use the reduction algorithms, which only work for arrays.

eithun commented 5 years ago

Is there any way I can accomplish this sort of task using the existing framework? For example, I've tried converting an image to an array by using the underlying buffer, but I haven't been successful.

inducer commented 5 years ago

Yes, I can see not-too-invasive ways in which the current code could be generalized to that setting. In terms of "the underlying buffer" of an image, I'm not sure there is such a thing.