| 2409 | } |
| 2410 | |
| 2411 | bool 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 | |
| 2428 | 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) { |
| 2429 | llama_file file(filepath, "rb"); |
no test coverage detected