Skip to content

Instantly share code, notes, and snippets.

@jrk
Created September 2, 2013 03:56
Show Gist options
  • Save jrk/6409103 to your computer and use it in GitHub Desktop.
Save jrk/6409103 to your computer and use it in GitHub Desktop.
#define AUTOTUNE_N 1024,1024
#include <Halide.h>
using namespace Halide;
int main(int argc, char **argv) {
ImageParam in_img(UInt(16), 2);
Func blur_x("blur_x"), blur_y("blur_y");
Var x("x"), y("y"), xi("xi"), yi("yi");
Func input;
input(x,y) = in_img(clamp(x, 1, in_img.width()-1),
clamp(y, 1, in_img.height())-1);
// The algorithm
blur_x(x, y) = (input(x, y) + input(x+1, y) + input(x+2, y))/3;
blur_y(x, y) = (blur_x(x, y) + blur_x(x, y+1) + blur_x(x, y+2))/3;
Halide::Var _x2;
input
.reorder_storage(y, x)
.compute_root();
blur_x
.split(x, x, _x2, 4)
.compute_at(blur_y, y);
blur_y
.reorder(y, x);
blur_y.compile_jit();
blur_y.infer_input_bounds(AUTOTUNE_N);
blur_y.realize(AUTOTUNE_N);
return 0;
}
@jrk
Copy link
Author

jrk commented Sep 2, 2013

Generated code segfaults, seemingly reading out of bounds in blur_x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment