In the filter I am implementing there is a step doing some reduction over the boundary of square domain
RDom r(0, filter_size, 0, filter_size);
r.where( (r.x == 0 || r.x == filter_size - 1)
|| (r.y == 0 || r.y == filter_size - 1));
However this makes domain traversal O(filter_size^2)
while useful reduction domain is only O(filter_size)
.
Now my reduction operation is a bit involved, so repeating if for each side of the filter window makes quite a mess. Is there an elegant && efficient way of doing this in Halide?