MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / state_seq_save_file

Method state_seq_save_file

subprojects/llama.cpp/src/llama-context.cpp:2471–2489  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2469}
2470
2471size_t llama_context::state_seq_save_file(llama_seq_id seq_id, const char * filepath, const llama_token * tokens, size_t n_token_count) {
2472 llama_file file(filepath, "wb");
2473
2474 file.write_u32(LLAMA_STATE_SEQ_MAGIC);
2475 file.write_u32(LLAMA_STATE_SEQ_VERSION);
2476
2477 // save the prompt
2478 file.write_u32((uint32_t) n_token_count);
2479 file.write_raw(tokens, sizeof(llama_token) * n_token_count);
2480
2481 // save the context state using stream saving
2482 llama_io_write_file io(&file);
2483 state_seq_write_data(io, seq_id, 0);
2484
2485 const size_t res = file.tell();
2486 GGML_ASSERT(res == sizeof(uint32_t) * 3 + sizeof(llama_token) * n_token_count + io.n_bytes());
2487
2488 return res;
2489}
2490
2491size_t llama_context::state_write_data(llama_io_write_i & io) {
2492 LLAMA_LOG_DEBUG("%s: writing state\n", __func__);

Callers 1

Calls 4

write_u32Method · 0.45
write_rawMethod · 0.45
tellMethod · 0.45
n_bytesMethod · 0.45

Tested by

no test coverage detected