From 13a329156f5ae51a0ffffcb0083d807da9e5b19f Mon Sep 17 00:00:00 2001 From: Jerry Ge Date: Mon, 3 Jul 2023 16:36:41 +0000 Subject: Support reading anydtype into a 32-bit buffer Signed-off-by: Jerry Ge Change-Id: Ic6b43539fcb2d75c5614d3addccd24a06e9f2a31 --- include/numpy_utils.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/numpy_utils.h b/include/numpy_utils.h index 29d7e11..e9c4bb4 100644 --- a/include/numpy_utils.h +++ b/include/numpy_utils.h @@ -1,5 +1,5 @@ -// Copyright (c) 2020-2021, ARM Limited. +// Copyright (c) 2020-2023, ARM Limited. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ public: FILE_TYPE_MISMATCH, HEADER_PARSE_ERROR, BUFFER_SIZE_MISMATCH, + DATA_TYPE_NOT_SUPPORTED, }; static NPError readFromNpyFile(const char* filename, const uint32_t elems, float* databuf); @@ -45,14 +46,6 @@ public: static NPError readFromNpyFile(const char* filename, const uint32_t elems, half_float::half* databuf); - static NPError readFromNpyFile(const char* filename, const uint32_t elems, uint8_t* databuf); - - static NPError readFromNpyFile(const char* filename, const uint32_t elems, int8_t* databuf); - - static NPError readFromNpyFile(const char* filename, const uint32_t elems, uint16_t* databuf); - - static NPError readFromNpyFile(const char* filename, const uint32_t elems, int16_t* databuf); - static NPError readFromNpyFile(const char* filename, const uint32_t elems, int32_t* databuf); static NPError readFromNpyFile(const char* filename, const uint32_t elems, int64_t* databuf); @@ -112,6 +105,7 @@ private: void* databuf, bool bool_translate); static NPError checkNpyHeader(FILE* infile, const uint32_t elems, const char* dtype_str); + static NPError getHeader(FILE* infile, bool& is_signed, int& bit_length, char& byte_order); static NPError writeNpyHeader(FILE* outfile, const std::vector& shape, const char* dtype_str); }; -- cgit v1.2.1