MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / gguf_write_out

Function gguf_write_out

external/ggml/src/gguf.cpp:1472–1508  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1470 memcpy(buf.data(), info.t.data, nbytes);
1471 }
1472 write(buf);
1473
1474 pad(alignment);
1475 }
1476};
1477
1478template <typename writer_t>
1479static void gguf_write_out(const struct gguf_context * ctx, writer_t & gw, bool only_meta) {
1480 const int64_t n_kv = gguf_get_n_kv(ctx);
1481 const int64_t n_tensors = gguf_get_n_tensors(ctx);
1482
1483 // write header
1484 gw.write(GGUF_MAGIC[0]);
1485 gw.write(GGUF_MAGIC[1]);
1486 gw.write(GGUF_MAGIC[2]);
1487 gw.write(GGUF_MAGIC[3]);
1488 gw.write(ctx->version);
1489 gw.write(n_tensors);
1490 gw.write(n_kv);
1491
1492 // write key-value pairs
1493 for (int64_t i = 0; i < n_kv; ++i) {
1494 gw.write(ctx->kv[i]);
1495 }
1496
1497 // write tensor info
1498 for (int64_t i = 0; i < n_tensors; ++i) {
1499 gw.write_tensor_meta(ctx->info[i]);
1500 }
1501
1502 // we require the data section to be aligned
1503 gw.pad(ctx->alignment);
1504
1505 if (only_meta) {
1506 return;
1507 }
1508
1509 const size_t offset_data = gw.written_bytes;
1510
1511 // write tensor data

Callers 2

gguf_write_to_bufFunction · 0.85
gguf_write_to_file_ptrFunction · 0.85

Calls 6

gguf_get_n_kvFunction · 0.85
gguf_get_n_tensorsFunction · 0.85
write_tensor_metaMethod · 0.80
padMethod · 0.80
writeMethod · 0.45
write_tensor_dataMethod · 0.45

Tested by

no test coverage detected