0

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?

1 Answer 1

2

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.