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

Method state_save_file

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

Source from the content-addressed store, hash-verified

2409}
2410
2411bool llama_context::state_save_file(const char * filepath, const llama_token * tokens, size_t n_token_count) {
2412 llama_file file(filepath, "wb");
2413
2414 file.write_u32(LLAMA_SESSION_MAGIC);
2415 file.write_u32(LLAMA_SESSION_VERSION);
2416
2417 // save the prompt
2418 file.write_u32((uint32_t) n_token_count);
2419 file.write_raw(tokens, sizeof(llama_token) * n_token_count);
2420
2421 // save the context state using stream saving
2422 llama_io_write_file io(&file);
2423 state_write_data(io);
2424
2425 return true;
2426}
2427
2428size_t llama_context::state_seq_load_file(llama_seq_id seq_id, const char * filepath, llama_token * tokens_out, size_t n_token_capacity, size_t * n_token_count_out) {
2429 llama_file file(filepath, "rb");

Callers 1

llama_state_save_fileFunction · 0.80

Calls 2

write_u32Method · 0.45
write_rawMethod · 0.45

Tested by

no test coverage detected