halide / Halide

a language for fast, portable data-parallel computation
https://halide-lang.org
Other
5.88k stars 1.07k forks source link

There is no way to declare Halide::Runtime::Buffer<float16> #3967

Open steven-johnson opened 5 years ago

steven-johnson commented 5 years ago

Halide::float16_t is a compiletime type, but there is no equivalent runtime type, and thus no overload for halide_type_of<>() which produces Float(16). You can of course work around this by using a dynamically-typed buffer, but static typing is good, so we should remedy this somehow.

steven-johnson commented 5 years ago

Did this get addressed as part of https://github.com/halide/Halide/pull/3667?

abadams commented 5 years ago

Hrm, no I don't think so, because float16_t is still defined in libHalide, not in the runtime. So you can use it as long as you link libHalide, (and type_of is defined there), which is not super useful unless you're jitting. We could consider making the float16 implementation in Float16.h/Float16.cpp part of the runtime too.

steven-johnson commented 5 years ago

Could we just add types to HalideRuntime.h that are strictly proxies for halide_type_of<>() for float16 and bfloat16?

alsrgv commented 4 years ago

That would be great!

jiawen commented 3 years ago

Bump.

steven-johnson commented 3 years ago

We could consider making the float16 implementation in Float16.h/Float16.cpp part of the runtime too.

Yeah, but that would require adding a fair amount of new runtime API surface area -- and a very C++-centric surface area, at that.

Thought: maybe we could add it as a new extra runtime header (HalideRuntimeFloat16.h?), so HalideRuntime.h doesn't get clogged with it? (This would require making an efficient header-only version of it, which might be tricky to do given the large data table in the .cpp file...)

ArunabhaDeb2018 commented 2 months ago

Hello All, Is it possible to do this now for fp16 data type Halide::Runtime::Buffer I have tried something like below _Float16* temp=new _Float16[1000] Buffer<_Float16>o(temp,1,1000); I get the below error But I get an expected a pointer type error. I am doing AOT compile wigh halide 16 for android ndk build. Kindly let me know if there is a way to use fp16 for halide buffers.