@@ -420,7 +420,7 @@ void load_state(llama_context* ctx, const char* dump_file_path){
420420 }
421421}
422422
423- void llama_context::mod_n_ctx (uint32_t new_n_ctx, llama_context_params params, const char * dump_file_path = " dump_state.bin " ){
423+ void llama_context::mod_n_ctx (uint32_t new_n_ctx, llama_context_params params){
424424 // Allow only to increase the context size.
425425 if (cparams.n_ctx < new_n_ctx) {
426426 cparams.n_ctx = new_n_ctx;
@@ -429,10 +429,14 @@ void llama_context::mod_n_ctx(uint32_t new_n_ctx, llama_context_params params, c
429429 /* .type_v =*/ params.type_v ,
430430 };
431431
432+ /*
432433 // Resets the memory and sets it to new memory params with modified cparams
433434 dump_state(this, dump_file_path); // Dump the state here.
434435 memory.reset(model.create_memory(params_mem, cparams));
435436 load_state(this, dump_file_path); // Load the state.
437+ */
438+
439+ memory.get ()->resize (new_n_ctx);
436440 }
437441 else {
438442 LLAMA_LOG_ERROR (" %s: Cannot decrease the context size." , __func__);
@@ -2293,8 +2297,8 @@ uint32_t llama_n_ctx(const llama_context * ctx) {
22932297 return ctx->n_ctx ();
22942298}
22952299
2296- void llama_mod_n_ctx (struct llama_context * ctx, uint32_t new_n_ctx, llama_context_params params, const char * dump_file_path ){
2297- ctx->mod_n_ctx (new_n_ctx, params, dump_file_path );
2300+ void llama_mod_n_ctx (struct llama_context * ctx, uint32_t new_n_ctx, llama_context_params params){
2301+ ctx->mod_n_ctx (new_n_ctx, params);
22982302}
22992303
23002304uint32_t llama_n_batch (const llama_context * ctx) {
0 commit comments