Use seekg to find file size instead

This commit is contained in:
Jed Fox 2023-03-23 16:18:29 -04:00
parent 1f9592baf3
commit 23035f9ba8
No known key found for this signature in database
GPG key ID: 0B61D18EA54B47E1

View file

@ -2,8 +2,6 @@
#include "ggml.h"
#include <sys/stat.h>
#include <cinttypes>
#include <fstream>
#include <random>
@ -417,12 +415,11 @@ static bool llama_model_load(
fin = std::ifstream(fname_part, std::ios::binary);
fin.rdbuf()->pubsetbuf(f_buf.data(), f_buf.size());
fin.seekg(file_offset);
// stat the file for file size
struct stat st;
stat(fname_part.c_str(), &st);
const size_t file_size = st.st_size;
fin.seekg(0, fin.end);
const size_t file_size = fin.tellg();
fin.seekg(file_offset);
// load weights
{