Skip to content

Commit bdade69

Browse files
committed
gguf: templated gguf write out
1 parent 9229898 commit bdade69

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

ggml/src/gguf.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,9 +1310,8 @@ struct gguf_writer_buf final : public gguf_writer_base {
13101310
}
13111311
};
13121312

1313-
void gguf_write_to_buf(const struct gguf_context * ctx, std::vector<int8_t> & buf, bool only_meta) {
1314-
gguf_writer_buf gw(buf);
1315-
1313+
template <typename Writer>
1314+
static void gguf_write_out(const struct gguf_context * ctx, Writer & gw, bool only_meta) {
13161315
const int64_t n_kv = gguf_get_n_kv(ctx);
13171316
const int64_t n_tensors = gguf_get_n_tensors(ctx);
13181317

@@ -1350,6 +1349,11 @@ void gguf_write_to_buf(const struct gguf_context * ctx, std::vector<int8_t> & bu
13501349
}
13511350
}
13521351

1352+
void gguf_write_to_buf(const struct gguf_context * ctx, std::vector<int8_t> & buf, bool only_meta) {
1353+
gguf_writer_buf gw(buf);
1354+
gguf_write_out(ctx, gw, only_meta);
1355+
}
1356+
13531357
bool gguf_write_to_file(const struct gguf_context * ctx, const char * fname, bool only_meta) {
13541358
FILE * file = ggml_fopen(fname, "wb");
13551359

0 commit comments

Comments
 (0)