MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / remap_layer

Function remap_layer

src/llama-quant.cpp:47–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47static std::string remap_layer(const std::string & orig_name, const std::vector<int> & prune, std::map<int, std::string> & mapped, int & next_id) {
48 if (prune.empty()) {
49 return orig_name;
50 }
51
52 static const std::regex pattern(R"(blk\.(\d+)\.)");
53 if (std::smatch match; std::regex_search(orig_name, match, pattern)) {
54 const int blk = std::stoi(match[1]);
55 std::string new_name = orig_name;
56
57 if (mapped.count(blk)) {
58 // Already mapped, do nothing
59 } else if (std::find(prune.begin(), prune.end(), blk) != prune.end()) {
60 mapped[blk] = "";
61 } else if (blk < prune.front()) {
62 mapped[blk] = std::to_string(blk);
63 next_id = blk + 1;
64 } else {
65 mapped[blk] = std::to_string(next_id);
66 ++next_id;
67 }
68
69 return mapped[blk].empty() ? mapped[blk] : new_name.replace(match.position(1), match.length(1), mapped[blk]);
70 }
71
72 return orig_name;
73}
74
75static std::string remap_imatrix(const std::string & orig_name, const std::map<int, std::string> & mapped) {
76 if (mapped.empty()) {

Callers 1

Calls 6

countMethod · 0.80
endMethod · 0.80
lengthMethod · 0.80
to_stringFunction · 0.50
emptyMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected