From b19af3643f68d2d1b9b27dd7cfd829f9dd33928e Mon Sep 17 00:00:00 2001 From: Pierrick HYMBERT Date: Fri, 22 Mar 2024 07:03:14 +0100 Subject: [PATCH] llama_model_loader: be sure the model mappings has enough capacity before allocating backend buffer --- llama.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/llama.cpp b/llama.cpp index 891892f25..3e0aec8f6 100644 --- a/llama.cpp +++ b/llama.cpp @@ -5135,9 +5135,11 @@ static bool llm_load_tensors( ml.done_getting_tensors(); ml.init_mappings(true, &model.mlock_mmaps); + model.mappings.reserve(ml.mappings.size()); // create the backend buffers std::vector>> ctx_bufs; + ctx_bufs.reserve(ctx_map.size()); // Ensure we have enough capacity for the maximum backend buffer we will potentially create size_t n_max_backend_buffer = ctx_map.size() * ml.files.size();