Skip to content

Commit b19af36

Browse files
committed
llama_model_loader: be sure the model mappings has enough capacity before allocating backend buffer
1 parent a9e88c6 commit b19af36

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

llama.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5135,9 +5135,11 @@ static bool llm_load_tensors(
51355135
ml.done_getting_tensors();
51365136

51375137
ml.init_mappings(true, &model.mlock_mmaps);
5138+
model.mappings.reserve(ml.mappings.size());
51385139

51395140
// create the backend buffers
51405141
std::vector<std::pair<ggml_context *, std::unordered_map<uint32_t, ggml_backend_buffer_t>>> ctx_bufs;
5142+
ctx_bufs.reserve(ctx_map.size());
51415143

51425144
// Ensure we have enough capacity for the maximum backend buffer we will potentially create
51435145
size_t n_max_backend_buffer = ctx_map.size() * ml.files.size();

0 commit comments

Comments
 (0)