Reputation: 11
I have two input images(rgb) in my generator pipeline. Each go through a custom crop and get resized to an NxNx3 image. The output of the generator Output<Buffer<float>> {"batch", 4}; // (N, N, 3 ,2)
and I set
batch(x, y, c, batch_size) = cast<float>(0);
batch(x, y, c, 0) = image_1_resized(x, y, c);
batch(x, y, c, 1) = image_2_resized(x, y, c);
but when I go to compile this it segfaults (I'm unable to retrieve useful debug info). If I try this:
clamped_image_1 = BoundaryConditions(image_1_resized, 0 ,{{0, N}, {0, N});
batch(x, y, c, batch_size) = cast<float>(0);
batch(x, y, c, 0) = image_1_resized(x, y, c);
batch(x, y, c, 1) = clamped_image_1(x + 10, y, c);
It compiles and works great. I'm curious to know, if what I'm trying to accomplish is possible with Halide?
Upvotes: 1
Views: 155
Reputation: 123
Instead of doing it as a multistage func, try using select to populate the different channels in a single stage.
batch(x, y, c, n) = select(n==0, image_1_resized(x, y, c), image_2_resized(x, y, c));
then you can schedule it by bounding and unrolling n, and halide will remove the branching:
batch.bound(n, 0, 2).unroll(n);
Upvotes: 3