I have this example generator that fills a region (0,0,100,100) with black:
class MyGen : public Generator<MyGen>
{
public:
Var x, y;
Output<Func> output { "output", Int(32), 2 };
void generate()
{
output(x, y) = x + y;
RDom dom = RDom(0, 100, 0, 100);
output(dom.x, dom.y) = 0;
}
void schedule()
{
}
};
The region is filled correctly, but because of the pure definition, the rest of the image is a gradient (x+y).
Is there a way to write a pure definition that's not going to be executed (e.g. output(x,y) = output(x,y))?
Can I execute a Func
over a specific domain (e.g. Input<int>
s that define the region) without impacting the rest of the image?
Here's how you write an unexecuted pure definition:
output(x, y) = undef<int>();
It's a bit dangerous though for anything other than outputs, because Halide doesn't statically check for use-of-undefined values. valgrind is your friend.