MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / state_save_file

Method state_save_file

smallthinker/src/llama-context.cpp:1674–1689  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1672}
1673
1674bool llama_context::state_save_file(const char * filepath, const llama_token * tokens, size_t n_token_count) {
1675 llama_file file(filepath, "wb");
1676
1677 file.write_u32(LLAMA_SESSION_MAGIC);
1678 file.write_u32(LLAMA_SESSION_VERSION);
1679
1680 // save the prompt
1681 file.write_u32((uint32_t) n_token_count);
1682 file.write_raw(tokens, sizeof(llama_token) * n_token_count);
1683
1684 // save the context state using stream saving
1685 llama_io_write_file io(&file);
1686 state_write_data(io);
1687
1688 return true;
1689}
1690
1691size_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) {
1692 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