0

I'm compiling a Func to a static library, and using it in a C program. I'm getting a message saying: Output buffer f20 has type int32 but elem_size of the buffer passed in is 1 instead of 4. I can't figure out what I'm doing wrong in this case. Here's the Func:

Var x, y, c;
Func out;
out(c, x, y) = cast<uint8_t>(255);

If I understand correctly, the resolved output type should be uint8_t. Here's how I'm creating my buffer in the C program:

buffer_t buffer;

buffer.extent[0] = 4;
buffer.extent[1] = width;
buffer.extent[2] = height;
buffer.elem_size = 1;
buffer.host = data;
buffer.stride[0] = 1;
buffer.stride[1] = 4;
buffer.stride[2] = stride;

fill_buffer(&buffer);

The buffer truly contains uint8_t values and I'm setting the elem_size to 1 so I don't understand how to make halide use it as 8 bit values..

1 Answer 1

0

Hard to give an answer here other than to confirm your expectation here is correct. If you compile out directly in a straight forward fashion, the output buffer elem_size should be 1. Question is why it is going wrong. If you compile with the HL_DEBUG_CODEGEN env variable set to 2 or higher, there will be debug output showing the IR that Halide is actually compiling. (Optionally you can call compile_to_lowered_stmt to dump the lowered IR to a file.) This might help show why this is not working.

There is a very slim chance it is a compiler issue, but more likely there is either stale code involved or you are not calling the filter being compiled from that code snippet.

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.