Open
Description
I'm getting the following unexpected behavior when trying to use the output buffer width()/height() in a generator before assigning the output buffer to a func. It gives an error during generation: Can't access output buffer of undefined Func
.
class Dummy : public Halide::Generator<Dummy> {
public:
Output<Buffer<int32_t>> output{"output", 3};
void generate() {
Var x,y,c;
//so this works fine:
//--------------------------------------
output(x,y,c) = x;
output(x,y,c) += output.width();
//--------------------------------------
// but below code crashes when running the generator (building generator works fine)
// with error: Unhandled exception: Error: Can't access output buffer of undefined Func. :
//--------------------------------------
// output(x,y,c) = x + output.width();
//--------------------------------------
// unfortunately this also means that scenario like the following does not work:
//--------------------------------------
//Func f_that_uses_output_width_in_ROI; // fill a quarter of the image for example, or
// take a histogram over a certain relative ROI
//...
//output(x,y,c) = ... // does not matter what is assigned here, but we somehow use f
// // so we have to define f before assigning something to output
// // we cannot assign output prior to f
//--------------------------------------
//schedule
output.compute_root();
}
};
It don't fully understand why, as I expect the output buffer size cannot be modified by an assigned Func (?). I can work around this by passing the sizes as extra parameters in the generator. But that does not seem a very clean approach. Maybe I'm overlooking something here...