https://github.com/halide/Halide
Raw File
Tip revision: d72f5591b9092bc2fa5c49d2f4761eef2be11c3d authored by Jonathan Ragan-Kelley on 13 June 2019, 23:09:37 UTC
Remove incorrect GCD reference from README
Tip revision: d72f559
simplestub_generator.cpp
#include "Halide.h"

namespace {

class SimpleStub : public Halide::Generator<SimpleStub> {
public:
    GeneratorParam<int> offset{"offset", 0};
    GeneratorParam<LoopLevel> compute_level{ "compute_level", LoopLevel::root() };

    Input<Buffer<uint8_t>> buffer_input{ "buffer_input", 2 };
    Input<Func> func_input{ "func_input", 2 };  // require a 2-dimensional Func but leave Type unspecified
    Input<float> float_arg{ "float_arg", 1.0f, 0.0f, 100.0f };

    Output<Func> simple_output{ "simple_output", Float(32), 2};

    void generate() {
        simple_output(x, y) = cast<float>(func_input(x, y)
            + offset + buffer_input(x, y)) + float_arg;
    }

    void schedule() {
        simple_output.compute_at(compute_level);
    }

private:
    Var x{"x"}, y{"y"};
};

}  // namespace

HALIDE_REGISTER_GENERATOR(SimpleStub, simplestub)
back to top