add llama_lora_adapter_clear (#8653)

This commit is contained in:
Xuan Son Nguyen 2024-07-24 11:25:19 +02:00 committed by GitHub
parent de280085e7
commit b115105f05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -529,12 +529,16 @@ extern "C" {
struct llama_lora_adapter * adapter, struct llama_lora_adapter * adapter,
float scale); 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 // Return -1 if the adapter is not present in the context
LLAMA_API int32_t llama_lora_adapter_remove( LLAMA_API int32_t llama_lora_adapter_remove(
struct llama_context * ctx, struct llama_context * ctx,
struct llama_lora_adapter * adapter); 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 // Manually free a LoRA adapter
// Note: loaded adapters will be free when the associated model is deleted // Note: loaded adapters will be free when the associated model is deleted
LLAMA_API void llama_lora_adapter_free(struct llama_lora_adapter * adapter); LLAMA_API void llama_lora_adapter_free(struct llama_lora_adapter * adapter);

View File

@ -16201,6 +16201,10 @@ int32_t llama_lora_adapter_remove(
return -1; 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) { void llama_lora_adapter_free(struct llama_lora_adapter * adapter) {
delete adapter; delete adapter;
} }