From 485a11d8cb67c8062c632f0987cd31cedbe93d6d Mon Sep 17 00:00:00 2001 From: James Ward Date: Fri, 5 Aug 2022 13:48:37 +0100 Subject: FP16 support in serialization * Allow serialization of fp16 data * Add package to support integrated half data-type (half_float::half), independent of native float: http://half.sourceforge.net/ * Allow passing of accumulate data-type in serialization Signed-off-by: James Ward Change-Id: I54357f02e3776d81958228f699ea5044f2014f4b --- src/numpy_utils.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/numpy_utils.cpp') diff --git a/src/numpy_utils.cpp b/src/numpy_utils.cpp index 80c680f..c770d45 100644 --- a/src/numpy_utils.cpp +++ b/src/numpy_utils.cpp @@ -14,6 +14,7 @@ // limitations under the License. #include "numpy_utils.h" +#include "half.hpp" // Magic NUMPY header static const char NUMPY_HEADER_STR[] = "\x93NUMPY\x1\x0\x76\x0{"; @@ -45,6 +46,13 @@ NumpyUtilities::NPError NumpyUtilities::readFromNpyFile(const char* filename, co return readFromNpyFileCommon(filename, dtype_str, sizeof(float), elems, databuf, false); } +NumpyUtilities::NPError + NumpyUtilities::readFromNpyFile(const char* filename, const uint32_t elems, half_float::half* databuf) +{ + const char dtype_str[] = "'& shape, + const half_float::half* databuf) +{ + const char dtype_str[] = "'