aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Johnson <jeremy.johnson@arm.com>2021-07-08 11:53:04 +0100
committerJeremy Johnson <jeremy.johnson@arm.com>2021-07-08 11:53:34 +0100
commit82dbb32980a58889bef28b7ad653c30694364195 (patch)
tree08acae6a0dd05ee81b6af39c386e4dd1488d4fdd
parent3bb1bc1189bfa14670d2f7839d708f443f5b5942 (diff)
downloadserialization_lib-82dbb32980a58889bef28b7ad653c30694364195.tar.gz
Allow reading numpy files with up to 10 dimensions.
Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com> Change-Id: Id6ee2aab2dd62b44e72b60218e4f03dc9a933d10
-rw-r--r--src/numpy_utils.cpp6
1 files changed, 4 insertions, 2 deletions
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)