This question is for the Halide language.
Say for a particular (x, y), I want to operate on a KxK patch around (x, y). E.g. sum them, square them, etc., to get the obtain the new value for (x, y).
Most of the Halide examples I've found "hard-code" selecting the neighboring coordinates. Like in this example, and also the blur algorithm example on the home page:
Func blur_x, blur_y; Var x, y;
// hard codes selecting x-1:x+1 and y-1:y+1
blur_x(x, y) = (input(x-1, y) + input(x, y) + input(x+1, y))/3;
blur_y(x, y) = (blur_x(x, y-1) + blur_x(x, y) + blur_x(x, y+1))/3;
But let's say I want to paramertize the size of my KxK patch. How would I select and then operate on a neighborhood of arbitrary size around (x, y)?