| 1672 | } |
| 1673 | |
| 1674 | bool 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 | |
| 1691 | size_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"); |
no test coverage detected