From 2f8cd979ecd1fa582852e7136e92ff8990b98fd8 Mon Sep 17 00:00:00 2001 From: Aaron Miller Date: Sat, 1 Jul 2023 11:14:59 -0700 Subject: metal : release buffers when freeing metal context (#2062) --- llama.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'llama.cpp') diff --git a/llama.cpp b/llama.cpp index 69c2ab0..561accf 100644 --- a/llama.cpp +++ b/llama.cpp @@ -253,7 +253,13 @@ struct llama_model { struct llama_context { llama_context(const llama_model & model, const llama_vocab & vocab) : model(model), vocab(vocab), t_load_us(model.t_load_us), t_start_us(model.t_start_us) {} - +#ifdef GGML_USE_METAL + ~llama_context() { + if (ctx_metal) { + ggml_metal_free(ctx_metal); + } + } +#endif std::mt19937 rng; bool has_evaluated_once = false; -- cgit v1.2.3