diff --git a/src/llama-mmap.cpp b/src/llama-mmap.cpp index 93496c3b7..02e4ede7c 100644 --- a/src/llama-mmap.cpp +++ b/src/llama-mmap.cpp @@ -5,7 +5,6 @@ #include "ggml.h" #include -#include #include #include #include @@ -32,9 +31,6 @@ #endif #include #include - #ifndef PATH_MAX - #define PATH_MAX MAX_PATH - #endif #include #endif @@ -1140,7 +1136,3 @@ void llama_prefetch(llama_memory_ranges mr) { GGML_UNUSED(mr); #endif } - -size_t llama_path_max() { - return PATH_MAX; -} diff --git a/src/llama-mmap.h b/src/llama-mmap.h index 6c6393d57..39715bfc3 100644 --- a/src/llama-mmap.h +++ b/src/llama-mmap.h @@ -88,5 +88,3 @@ using llama_memory_ranges = std::vector; // Prefetch the host pages covering these memory ranges. void llama_prefetch(llama_memory_ranges mr); - -size_t llama_path_max(); diff --git a/src/llama-model-loader.cpp b/src/llama-model-loader.cpp index 548ade101..808fb44d8 100644 --- a/src/llama-model-loader.cpp +++ b/src/llama-model-loader.cpp @@ -84,7 +84,7 @@ const char * llama_ftype_name(llama_ftype ftype) { static std::vector llama_get_list_splits(const std::string & path, const int idx, const int n_split) { std::vector paths; std::string split_prefix; - std::vector buf(llama_path_max(), 0); + std::vector buf(path.size() + 1, 0); { int ret = llama_split_prefix(buf.data(), buf.size(), path.c_str(), idx, n_split); @@ -610,7 +610,7 @@ llama_model_loader::llama_model_loader( throw std::runtime_error(format("illegal split file idx: %d (file: %s), model must be loaded with the first split", idx, fname.c_str())); } - std::vector prefix(llama_path_max(), 0); + std::vector prefix(fname.size() + 1, 0); if (paths.empty() || llama_split_prefix(prefix.data(), prefix.size(), fname.c_str(), idx, n_split)) { auto backbone = llama_get_list_splits(fname, idx, n_split); auto file_name = [](const std::string & path) { diff --git a/src/llama-quant.cpp b/src/llama-quant.cpp index 0f3f982b0..79d964972 100644 --- a/src/llama-quant.cpp +++ b/src/llama-quant.cpp @@ -1266,7 +1266,7 @@ static void llama_model_quantize_impl(const std::string & fname_inp, const std:: GGML_ASSERT(ctx_outs[cur_split] && "Find uninitialized gguf_context"); std::string fname = fname_out; if (params->keep_split) { - std::vector split_path(llama_path_max(), 0); + std::vector split_path(fname_out.size() + sizeof("-00000-of-00000.gguf"), 0); llama_split_path(split_path.data(), split_path.size(), fname_out.c_str(), cur_split, n_split); fname = std::string(split_path.data()); }