https://github.com/halide/Halide
Raw File
Tip revision: 3f7e8908b8871d1ce167037b5f877a664c044358 authored by Steven Johnson on 14 April 2022, 20:25:29 UTC
Python: make Func implicitly convertible to Stage (#6702) (#6708)
Tip revision: 3f7e890
haar_x_generator.cpp
#include "Halide.h"

#include "daubechies_constants.h"

namespace {

Halide::Var x("x"), y("y"), c("c");

class haar_x : public Halide::Generator<haar_x> {
public:
    Input<Buffer<float, 2>> in_{"in"};
    Output<Buffer<float, 3>> out_{"out"};

    void generate() {
        Func in = Halide::BoundaryConditions::repeat_edge(in_);

        out_(x, y, c) = mux(c,
                            {(in(2 * x, y) + in(2 * x + 1, y)),
                             (in(2 * x, y) - in(2 * x + 1, y))}) /
                        2;
        out_.unroll(c, 2);
    }
};

}  // namespace

HALIDE_REGISTER_GENERATOR(haar_x, haar_x)
back to top