From 715be86f4c3d004f88380b9aa56f795d1a565233 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Thu, 4 Apr 2024 10:37:02 -0700 Subject: [PATCH] Add conversion code for Float16 that was missed in #8174 --- tools/halide_image_io.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/halide_image_io.h b/tools/halide_image_io.h index 1e0cbff01897..ff23c30aa995 100644 --- a/tools/halide_image_io.h +++ b/tools/halide_image_io.h @@ -2227,6 +2227,10 @@ struct ImageTypeConversion { const halide_type_t src_type = src.type(); switch (src_type.element_of().as_u32()) { +#ifdef HALIDE_CPP_COMPILER_HAS_FLOAT16 + case halide_type_t(halide_type_float, 16).as_u32(): + return convert_image(src.template as<_Float16, AnyDims>()); +#endif case halide_type_t(halide_type_float, 32).as_u32(): return convert_image(src.template as()); case halide_type_t(halide_type_float, 64).as_u32(): @@ -2272,6 +2276,10 @@ struct ImageTypeConversion { // Call the appropriate static-to-static conversion routine // based on the desired dst type. switch (dst_type.element_of().as_u32()) { +#ifdef HALIDE_CPP_COMPILER_HAS_FLOAT16 + case halide_type_t(halide_type_float, 16).as_u32(): + return convert_image<_Float16>(src); +#endif case halide_type_t(halide_type_float, 32).as_u32(): return convert_image(src); case halide_type_t(halide_type_float, 64).as_u32():