Closed amisal88 closed 7 years ago
Others can give a more authoritative response, but the short answer is that you can't do this with the current paradigm. The Halide-HLS compiler assumes that the image can be streamed through the processing pipeline, which means that only a few lines of the image are stored in the hardware at once. To subtract the mean from the whole image, you need to have read in all the pixels before processing the first output pixel, which would require that entire image be stored on-chip.
If you want to do this, you'll need to do it in two passes, one which computes the mean, and a second which subtracts that from each pixel. In practice, both of these operations are going to be memory-bound (rather than compute-bound), so it's very unlikely that you'll see any speedup versus running on CPU.
@stevenbell Thank you very much for your response.
I am trying to implement simple algorithm in Halide-HLS which requires reduction sum on the whole image to compute the average. The "pipeline.cpp" file is attached below.
Running "make pipeline_hls.cpp" results in following error:
changing the definition of pipeline from:
to
results in following error:
But changing this line
to
works, but the extracted "hls_target" function is not efficient, since it computes the average again for each pixel.
Any idea to compute and use image average efficiently?
Thanks!
Attachment: Content of "pipeline.cpp" file: