halide / Halide

a language for fast, portable data-parallel computation
https://halide-lang.org
Other
5.87k stars 1.07k forks source link

Is it possible to implement Patchmatch algorithm in Halide? #5945

Closed jiangsutx closed 3 years ago

jiangsutx commented 3 years ago

Hi everyone,

I hope to run patchmatch on cuda and on mobile devices. It is possible to implement in Halide? To my understand, patchmatch requires process from left to right and top to bottom. It is not purely pixel-wise independant.

Thank you in advance for your help.

abadams commented 3 years ago

In the past I have tried and failed. The issue is not just that it's serial - we can handle that. The issue is that the serial dependence needs another Func inside the loop to compute differences over patches, so you get an imaging pipeline with a loop in it.

To put it another way, we can handle a Func that depends on itself at another location. What we can't handle is Func A depends on Func B, which in turn depends on Func A at a different location.

jiangsutx commented 3 years ago

Thanks for your reply. Yeah, I searched through halide repo and found a draft for patchmatch.

Then is it possible to just parallelize some inner Func and use normal programming for outer Func? Do you know other nearest neighbour search method that best suit halide?

Thanks very much for your help.