Ejemplo n.º 1
0
    Func build() {
        Expr width = input.width();
        Expr height = input.height();
        
        Expr width_kernel = K.width();
        Expr height_kernel = K.height();

        //Input
        Func input_func("in");
        input_func(x, y, c) = input(x, y, c);
        
        //Input H
        Func K_func("K");
        K_func(i, j, c) = K(i, j, c);

        //Warping
        Func conv_input = A_conv(input_func, width, height, K_func, width_kernel, height_kernel);

        //Allow for arbitrary strides
        input.set_stride(0, Expr());
        K.set_stride(0, Expr());
        conv_input.output_buffer().set_stride(0, Expr()); 

        return conv_input;
    }
Ejemplo n.º 2
0
    Func build() {
        Expr width = input.width();
        Expr height = input.height();
        
        //Input
        Func input_func("in");
        input_func(x, y, c) = input(x, y, c);

        //Warping
        Func K_input = K_grad_mat(input_func, width, height);

        //Allow for arbitrary strides
        input.set_stride(0, Expr());
        K_input.output_buffer().set_stride(0, Expr()); 

        return K_input;
    }
Ejemplo n.º 3
0
    Func build() override {
        Expr width = input.width();
        Expr height = input.height();

        // Our input is an ImageParam, but blur_cols takes a Func, so
        // we define a trivial func to wrap the input.
        Func input_func;
        input_func(x, y, c) = input(x, y, c);

        // First, blur the columns of the input.
        Func blury_T = blur_cols_transpose(input_func, height, alpha);

        // Blur the columns again (the rows of the original).
        Func blur = blur_cols_transpose(blury_T, width, alpha);

        // Scheduling is done inside blur_cols_transpose.

        return blur;
    }
Ejemplo n.º 4
0
/* Do n unrolled iterations of game of life on a torus */
Func gameOfLife(ImageParam input, int n) {
    Var x, y;
    Func in;
    if (n == 1) {
        in(x, y) = input(x, y);
    } else {
        in = gameOfLife(input, n-1);
        in.compute_root();
    }

    Expr w = input.width(), h = input.height();
    Expr W = (x+w-1) % w, E = (x+1) % w, N = (y+h-1) % h, S = (y+1) % h;
    Expr livingNeighbors = (in(W, N) + in(x, N) +
                            in(E, N) + in(W, y) + 
                            in(E, y) + in(W, S) +
                            in(x, S) + in(E, S));    
    Expr alive = in(x, y) != 0;
    Func output;
    output(x, y) = select(livingNeighbors == 3 || (alive && livingNeighbors == 2), u8(1), u8(0));    

    return output;
}
Ejemplo n.º 5
0
    Func build() {

        Expr width = input.width();
        Expr height = input.height();
        Expr nhom = H.channels();

        //Input
        Func input_func("in");
        input_func(x, y, c) = input(x, y, c);
        
        //Input H
        Func H_func("H");
        H_func(i, j, g) = H(i, j, g);

        //Warping
        Func warp_input = A_warpHomography(input_func, width, height, H_func, nhom);
       
        //Allow for arbitrary strides
        input.set_stride(0, Expr());
        H.set_stride(0, Expr());
        warp_input.output_buffer().set_stride(0, Expr()); 

        return warp_input;
    }