From 07f41cafee6d6ba8fccd94562c89a40cd2eeb18b Mon Sep 17 00:00:00 2001 From: Kevin Pouget Date: Thu, 29 Jan 2026 09:50:47 +0100 Subject: [PATCH] ggml-virtgpu: add a cleanup function for consistency --- ggml/src/ggml-virtgpu/ggml-backend-reg.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ggml/src/ggml-virtgpu/ggml-backend-reg.cpp b/ggml/src/ggml-virtgpu/ggml-backend-reg.cpp index ca8235bb65..7256737c63 100644 --- a/ggml/src/ggml-virtgpu/ggml-backend-reg.cpp +++ b/ggml/src/ggml-virtgpu/ggml-backend-reg.cpp @@ -4,6 +4,8 @@ #include #include +void ggml_virtgpu_cleanup(virtgpu *gpu); + static virtgpu * apir_initialize() { static virtgpu * gpu = NULL; static std::atomic initialized = false; @@ -170,3 +172,21 @@ ggml_backend_reg_t ggml_backend_virtgpu_reg() { } GGML_BACKEND_DL_IMPL(ggml_backend_virtgpu_reg) + +// public function, not exposed in the GGML interface at the moment +void ggml_virtgpu_cleanup(virtgpu *gpu) { + if (gpu->cached_device_info.name) { + free(gpu->cached_device_info.name); + gpu->cached_device_info.name = NULL; + } + if (gpu->cached_device_info.description) { + free(gpu->cached_device_info.description); + gpu->cached_device_info.description = NULL; + } + if (gpu->cached_buffer_type.name) { + free(gpu->cached_buffer_type.name); + gpu->cached_buffer_type.name = NULL; + } + + mtx_destroy(&gpu->data_shmem_mutex); +}