I'm trying to figure out how to implement max pooling on Arrayfire. My current best approach involves iterating over each convolved output and apply a function which applies four kernels, [1 0 0 0], [0 1 0 0], [0 0 1 0], [0 0 0 1], and produces four outputs, which I can then compare for the maximum value at each pixel.
My issue with that is it seems terribly slow and incorrect to be looping like that in a tensor library, but I haven't been able to come up with a better solution
You can use wrap and unwrap to perform this, perhaps more efficiently.
here is the logic:
I would think this could potentially be more faster indexing offset locations which can result less than ideal memory reads.
Here are the links to relevant documentation for above mentioned functions
unwrap - https://arrayfire.org/arrayfire-rust/arrayfire/fn.unwrap.html wrap - https://arrayfire.org/arrayfire-rust/arrayfire/fn.wrap.html
Although I did write an example in rust documentation, image illustrations on C++ documentation are far better in terms of understanding whats happening I think. Given below are those links
unwrap - https://arrayfire.org/docs/group__image__func__unwrap.htm wrap - https://arrayfire.org/docs/group__image__func__wrap.htm
Hopefully, this helps