Browse Source

fixs

pull/6227/head
AtomAlpaca 11 months ago
parent
commit
a9c340982d
No known key found for this signature in database GPG Key ID: A003E4A074A5B2CA
2 changed files with 7 additions and 4 deletions
  1. +3
    -2
      tools/pnnx/src/main.cpp
  2. +4
    -2
      tools/pnnx/src/utils.cpp

+ 3
- 2
tools/pnnx/src/main.cpp View File

@@ -163,8 +163,9 @@ static bool file_maybe_numpy(const std::string& path)
return false;
}
char signature[6];
char signature[7];
fread(signature, sizeof(char), 6, fp);
signature[6] = '\0';

fclose(fp);

@@ -180,7 +181,7 @@ static void prase_numpy_file_list(char* s, std::vector<std::vector<int64_t> >& s
{
if (!file_maybe_numpy(s))
{
fprintf(stderr, "%s is not a vaild numpy file", s);
fprintf(stderr, "%s is not a vaild numpy file", s.c_str());
return ;
}
pnnx::prase_numpy_file(s.c_str(), shapes, types, contents);


+ 4
- 2
tools/pnnx/src/utils.cpp View File

@@ -4,6 +4,7 @@
#include "utils.h"

#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <math.h>

@@ -151,7 +152,8 @@ void prase_dtype(char* dtype, std::vector<std::string>& types, char& endian)
std::string s;
s += dtype[0];
char p[10];
s += itoa(8 * atoi(dtype + 1), p, 10);
sprintf(p, "%d", 8 * atoi(dtype + 1));
s += p;
types.push_back(s);
}

@@ -284,7 +286,7 @@ void prase_numpy_file(const char * path,
fclose(fp);
return ;
}
char magic[6];
fread(magic, sizeof(char), 6, fp);



Loading…
Cancel
Save