From 30144f7634c619aa222d193392c910a663676186 Mon Sep 17 00:00:00 2001 From: l3utterfly Date: Thu, 3 Aug 2023 21:03:15 +0800 Subject: [PATCH] restored save load state example --- examples/save-load-state/save-load-state.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/save-load-state/save-load-state.cpp b/examples/save-load-state/save-load-state.cpp index b1856e592..2b43e1d80 100644 --- a/examples/save-load-state/save-load-state.cpp +++ b/examples/save-load-state/save-load-state.cpp @@ -67,9 +67,10 @@ int main(int argc, char ** argv) { // Save state (rng, logits, embedding and kv_cache) to file { - llama_file file("dump_state.bin", "wb"); - llama_data_file_context data_ctx(&file); - llama_copy_state_data(ctx, &data_ctx); // can also copy to memory buffer + FILE *fp_write = fopen("dump_state.bin", "wb"); + llama_copy_state_data(ctx, state_mem); // could also copy directly to memory mapped file + fwrite(state_mem, 1, state_size, fp_write); + fclose(fp_write); } // save state (last tokens)