MCPcopy Create free account
hub / github.com/Niko1221/Strata / write_gguf

Function write_gguf

engine/src/split/tools/convert_parallel_test.cpp:76–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74void put64(std::vector<uint8_t>& o, uint64_t v) { o.insert(o.end(), (uint8_t*) &v, (uint8_t*) &v + 8); }
75
76bool write_gguf(const std::string& path, const std::vector<Spec>& ts) {
77 std::vector<uint8_t> o;
78 put32(o, 0x46554747u);
79 put32(o, 3);
80 put64(o, ts.size());
81 put64(o, 0); // no metadata
82 uint64_t off = 0;
83 for (const Spec& t : ts) {
84 put64(o, t.name.size());
85 o.insert(o.end(), t.name.begin(), t.name.end());
86 put32(o, (uint32_t) t.ne.size());
87 for (uint64_t e : t.ne) put64(o, e);
88 put32(o, t.type);
89 put64(o, off);
90 off += (t.data.size() + 31) / 32 * 32;
91 }
92 while (o.size() % 32) o.push_back(0);
93 for (const Spec& t : ts) {
94 o.insert(o.end(), t.data.begin(), t.data.end());
95 while (o.size() % 32) o.push_back(0);
96 }
97 std::FILE* f = std::fopen(path.c_str(), "wb");
98 if (!f) return false;
99 const bool ok = std::fwrite(o.data(), 1, o.size(), f) == o.size();
100 std::fclose(f);
101 return ok;
102}
103
104} // namespace
105

Callers 1

mainFunction · 0.70

Calls 8

put64Function · 0.85
push_backMethod · 0.80
put32Function · 0.70
sizeMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected