This source file includes following definitions.
- verify
- main
#include "Halide.h"
#include "example.stub.h"
using Halide::Buffer;
const int kSize = 32;
void verify(const Buffer<int32_t> &img, float compiletime_factor, float runtime_factor, int channels) {
img.for_each_element([=](int x, int y, int c) {
int expected = (int32_t)(compiletime_factor * runtime_factor * c * (x > y ? x : y));
int actual = img(x, y, c);
assert(expected == actual);
});
}
int main(int argc, char **argv) {
Halide::JITGeneratorContext context(Halide::get_target_from_environment());
{
example::Inputs inputs;
inputs.runtime_factor = 1.f;
example::GeneratorParams gp;
gp.compiletime_factor = 2.5f;
gp.enummy = Enum_enummy::foo;
auto gen = example(context, inputs, gp);
gen.schedule();
Halide::Buffer<int32_t> img = gen.realize(kSize, kSize, 3);
verify(img, 2.5f, 1, 3);
}
{
auto gen = example(context, { 1.f });
gen.vectorize.set(false);
gen.schedule();
Halide::Buffer<int32_t> img(kSize, kSize, 3);
gen.realize(img);
verify(img, 1, 1, 3);
}
printf("Success!\n");
return 0;
}