root/test/correctness/autotune_bug.cpp

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. main

#define AUTOTUNE_N 16,16

// This tests a segfault generated by an autotuned schedule.

#include "Halide.h"
#include <stdio.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);
    assert(in_img.get().data());
    blur_y.realize(AUTOTUNE_N);

    printf("Success!\n");
    return 0;
}

/* [<][>][^][v][top][bottom][index][help] */