0

I'm trying to translate the resize app from the halide repository from the inline declarations to a generator. Everything seems to work fine, except for this:

Func clamped = BoundaryConditions::repeat_edge(input);`

In the original code, input is declared like so ImageParam input(Float(32), 3). In my generator, I've translated this to: Input<Func> input { "input", Float(32), 3 }. I'm then declaring the clamped in the exact same way as the original code. When compiling, I'm getting this error:

Halide.h:15202:50: error: no member named 'dim' in 'Halide::GeneratorInput<Halide::Func>'
    object_bounds.push_back({ Expr(func_like.dim(i).min()), Expr(func_like.dim(i).extent()) });
                                   ~~~~~~~~~ ^

Is there a way to create a BoundaryConditions::repeat_edge on an Input<Func>?

Philippe Paré
  • 4,279
  • 5
  • 36
  • 56

2 Answers2

1

The idea of Input<Func> is that it may be instantiated with another Func when composing generators together. (E.g. the output of one generator may be the input to another and the graph of all connected generators is compiled as a single Halide program.) The problem is Funcs do not have fixed bounds like Buffers do. Hence one cannot ask for (e.g.) the width of a Func.

For a generator which is designed to always be used with concrete memory, one can use Input. To impose a boundary condition on an Input, the bounds need to be passed as explicit parameters to the generator. E.g. as other Inputs.

Zalman Stern
  • 3,161
  • 12
  • 18
1

There is, associate a Buffer<> with it. (Maybe a Buffer in your case, try it out).

 struct MyGen : Generator<MyGen> {
     Input<Buffer<>> dim_only_input_buffer{ "dim_only_input_buffer", 3 }; 
     ... 
  };

I ran into something similar, you can see more about this in this github issue

Ashish Uthama
  • 1,331
  • 1
  • 9
  • 14