MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / ggml_free

Function ggml_free

ggml.c:2279–2306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2277}
2278
2279void ggml_free(struct ggml_context * ctx) {
2280 // make this function thread safe
2281 ggml_critical_section_start();
2282
2283 bool found = false;
2284
2285 for (int i = 0; i < GGML_MAX_CONTEXTS; i++) {
2286 if (&g_state.contexts[i].context == ctx) {
2287 g_state.contexts[i].used = false;
2288
2289 GGML_PRINT_DEBUG("%s: context %d has been freed. memory used = %zu\n",
2290 __func__, i, ggml_used_mem(ctx));
2291
2292 if (ctx->mem_buffer_owned) {
2293 GGML_ALIGNED_FREE(ctx->mem_buffer);
2294 }
2295
2296 found = true;
2297 break;
2298 }
2299 }
2300
2301 if (!found) {
2302 GGML_PRINT_DEBUG("%s: context not found\n", __func__);
2303 }
2304
2305 ggml_critical_section_end();
2306}
2307
2308size_t ggml_used_mem(const struct ggml_context * ctx) {
2309 return ctx->objects_end == NULL ? 0 : ctx->objects_end->offs + ctx->objects_end->size;

Callers 15

ggml_optFunction · 0.70
gguf_init_from_fileFunction · 0.70
~llama_kv_cacheMethod · 0.70
~llama_modelMethod · 0.70
~llama_model_loaderMethod · 0.70
sum_gpu_indexFunction · 0.70
freeMethod · 0.70
llama_backend_initFunction · 0.70
llama_set_state_dataFunction · 0.70
sched_split_graphFunction · 0.70

Calls 3

ggml_used_memFunction · 0.70

Tested by 5

mainFunction · 0.40
mainFunction · 0.40
mainFunction · 0.40
mainFunction · 0.40
mainFunction · 0.40