diff options
author | Xuan Son Nguyen <thichthat@gmail.com> | 2024-04-28 17:36:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-28 17:36:18 +0200 |
commit | 7bb36ccf91b8a2e92b182dd75624f1fd7cb205ac (patch) | |
tree | ab92b14895245a23730553dc06af68e75995c69c /llama.cpp | |
parent | ce023f6f2ff34fbe840e32e65d443d2fed7393de (diff) |
gguf : enforce that tensor names are unique (#6905)
* not allow adding duplicated tensor name
* no duplicated tensor while reading gguf
* typo
* throw exception inside llama_model_loader
Co-authored-by: slaren <slarengh@gmail.com>
---------
Co-authored-by: slaren <slarengh@gmail.com>
Diffstat (limited to 'llama.cpp')
-rw-r--r-- | llama.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -3120,9 +3120,17 @@ struct llama_model_loader { fver = (enum llama_fver) gguf_get_version(meta); + std::set<std::string> tensor_names; for (auto & w : weights) { n_elements += ggml_nelements(w.tensor); n_bytes += ggml_nbytes(w.tensor); + // make sure there is no duplicated tensor names + const std::string name(w.tensor->name); + auto found = tensor_names.find(name); + if (found != tensor_names.end()) { + throw std::runtime_error(format("invalid model: tensor '%s' is duplicated", w.tensor->name)); + } + tensor_names.insert(name); } LLAMA_LOG_INFO("%s: loaded meta data with %d key-value pairs and %d tensors from %s (version %s)\n", |