From 82dbb32980a58889bef28b7ad653c30694364195 Mon Sep 17 00:00:00 2001 From: Jeremy Johnson Date: Thu, 8 Jul 2021 11:53:04 +0100 Subject: Allow reading numpy files with up to 10 dimensions. Signed-off-by: Jeremy Johnson Change-Id: Id6ee2aab2dd62b44e72b60218e4f03dc9a933d10 --- src/numpy_utils.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/numpy_utils.cpp b/src/numpy_utils.cpp index e438235..3c85ae1 100644 --- a/src/numpy_utils.cpp +++ b/src/numpy_utils.cpp @@ -18,6 +18,8 @@ // Magic NUMPY header static const char NUMPY_HEADER_STR[] = "\x93NUMPY\x1\x0\x76\x0{"; static const int NUMPY_HEADER_SZ = 128; +// Maximum shape dimensions supported +static const int NUMPY_MAX_DIMS_SUPPORTED = 10; NumpyUtilities::NPError NumpyUtilities::readFromNpyFile(const char* filename, const uint32_t elems, bool* databuf) { @@ -189,11 +191,11 @@ NumpyUtilities::NPError NumpyUtilities::checkNpyHeader(FILE* infile, const uint3 while (isspace(*ptr)) ptr++; - // The shape contains N comma-separated integers. Read up to 4. + // The shape contains N comma-separated integers. Read up to MAX_DIMS. char* end = NULL; ptr = strtok_r(ptr, ",", &end); - for (int i = 0; i < 4; i++) + for (int i = 0; i < NUMPY_MAX_DIMS_SUPPORTED; i++) { // Out of dimensions if (!ptr) -- cgit v1.2.1