use sorted map, sort weights by layer
This commit is contained in:
parent
13eba91a32
commit
9a99293174
1 changed files with 15 additions and 1 deletions
|
@ -4284,7 +4284,21 @@ struct llama_model_loader {
|
|||
}
|
||||
};
|
||||
|
||||
std::unordered_map<std::string, struct llama_tensor_weight> weights_map;
|
||||
// custom comparator to sort weights more nicely by layer
|
||||
struct weight_name_comparer {
|
||||
bool operator()(const std::string & a, const std::string & b) const {
|
||||
int a_layer = -1;
|
||||
int b_layer = -1;
|
||||
sscanf(a.c_str(), "blk.%d.", &a_layer);
|
||||
sscanf(b.c_str(), "blk.%d.", &b_layer);
|
||||
if (a_layer != b_layer) {
|
||||
return a_layer < b_layer;
|
||||
}
|
||||
return a < b;
|
||||
}
|
||||
};
|
||||
|
||||
std::map<std::string, struct llama_tensor_weight, weight_name_comparer> weights_map;
|
||||
std::unordered_map<std::string, struct llama_model_kv_override> kv_overrides;
|
||||
|
||||
struct gguf_context * meta = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue