]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
vocab : call reserve() for building plamo-2-translate suffix (#17343)
authorHaiyue Wang <redacted>
Tue, 18 Nov 2025 17:58:22 +0000 (01:58 +0800)
committerGitHub <redacted>
Tue, 18 Nov 2025 17:58:22 +0000 (18:58 +0100)
Test 'Q4_K_M' quantization on https://huggingface.co/pfnet/plamo-2-translate

The 'suffix_to_score' size is 193510, it needs 19 memory allocation with final
capacity 262144 to hold the value, if not preserve the memory.

Signed-off-by: Haiyue Wang <redacted>
src/llama-vocab.cpp

index 29e31cecd1565c804972a79286e3c0bb207d9cfe..a73c4c448ba536fd75aec4e4c67c1de08602c686 100644 (file)
@@ -1281,6 +1281,7 @@ struct llm_tokenizer_plamo2 : llm_tokenizer {
 
         // Build suffix list in lexicographical order of reversed strings
         std::vector<std::string> suffixes;
+        suffixes.reserve(suffix_to_score.size() + 1);
         for (const auto & pair : suffix_to_score) {
             suffixes.push_back(pair.first);
         }