From b115105f05e3372bc75b2a486c1930c365fd2846 Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Wed, 24 Jul 2024 11:25:19 +0200 Subject: [PATCH] add llama_lora_adapter_clear (#8653) --- include/llama.h | 6 +++++- src/llama.cpp | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/llama.h b/include/llama.h index e68cd807e..413070d95 100644 --- a/include/llama.h +++ b/include/llama.h @@ -529,12 +529,16 @@ extern "C" { struct llama_lora_adapter * adapter, float scale); - // Remove a LoRA adapter from given context + // Remove a specific LoRA adapter from given context // Return -1 if the adapter is not present in the context LLAMA_API int32_t llama_lora_adapter_remove( struct llama_context * ctx, struct llama_lora_adapter * adapter); + // Remove all LoRA adapters from given context + LLAMA_API void llama_lora_adapter_clear( + struct llama_context * ctx); + // Manually free a LoRA adapter // Note: loaded adapters will be free when the associated model is deleted LLAMA_API void llama_lora_adapter_free(struct llama_lora_adapter * adapter); diff --git a/src/llama.cpp b/src/llama.cpp index 40c5e8e8d..04eaf6730 100644 --- a/src/llama.cpp +++ b/src/llama.cpp @@ -16201,6 +16201,10 @@ int32_t llama_lora_adapter_remove( return -1; } +void llama_lora_adapter_clear(struct llama_context * ctx) { + ctx->lora_adapters.clear(); +} + void llama_lora_adapter_free(struct llama_lora_adapter * adapter) { delete adapter; }