#include "Halide.h"
#include <stdio.h>
int main(int argc, char **argv) {
{
Func gradient(
"gradient");
gradient(x, y) = x + y;
printf("Evaluating gradient\n");
Func parallel_gradient(
"parallel_gradient");
parallel_gradient(x, y) = x + y;
printf("\nEvaluating parallel_gradient\n");
}
{
f(x, y) = sin(x) + cos(y);
g(x, y) = sin(x) + print(cos(y));
printf("\nEvaluating sin(x) + cos(y), and just printing cos(y)\n");
}
{
f(x, y) = sin(x) + print(cos(y), "<- this is cos(", y, ") when x =", x);
printf("\nEvaluating sin(x) + cos(y), and printing cos(y) with more context\n");
g(x, y) = sin(x) + e;
}
{
e = print_when(x == 37 && y == 42, e, "<- this is cos(y) at x, y == (37, 42)");
f(x, y) = sin(x) + e;
printf("\nEvaluating sin(x) + cos(y), and printing cos(y) at a single pixel\n");
e = cos(y);
e = print_when(e < 0, e, "cos(y) < 0 at y ==", y);
g(x, y) = sin(x) + e;
printf("\nEvaluating sin(x) + cos(y), and printing whenever cos(y) < 0\n");
}
{
Var fizz(
"fizz"), buzz(
"buzz");
for (int i = 2; i < 100; i++) {
if (i % 3 == 0 && i % 5 == 0) {
e += fizz * buzz;
} else if (i % 3 == 0) {
e += fizz;
} else if (i % 5 == 0) {
e += buzz;
} else {
e += i;
}
}
std::cout << "Printing a complex Expr: " << e << "\n";
}
printf("Success!\n");
return 0;
}
A Halide::Buffer is a named shared reference to a Halide::Runtime::Buffer.
Func & trace_stores()
Trace all stores to the buffer backing this Func by emitting calls to halide_trace.
Realization realize(std::vector< int32_t > sizes={}, const Target &target=Target())
Evaluate this function over some rectangular domain and return the resulting buffer or buffers.
Func & parallel(const VarOrRVar &var)
Mark a dimension to be traversed in parallel.
A Halide variable, to be used when defining functions.
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
A fragment of Halide syntax.