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

Function gguf_free

ggml.c:19761–19812  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19759}
19760
19761void gguf_free(struct gguf_context * ctx) {
19762 if (ctx == NULL) {
19763 return;
19764 }
19765
19766 if (ctx->kv) {
19767 // free string memory - not great..
19768 for (uint32_t i = 0; i < ctx->header.n_kv; ++i) {
19769 struct gguf_kv * kv = &ctx->kv[i];
19770
19771 if (kv->key.data) {
19772 free(kv->key.data);
19773 }
19774
19775 if (kv->type == GGUF_TYPE_STRING) {
19776 if (kv->value.str.data) {
19777 free(kv->value.str.data);
19778 }
19779 }
19780
19781 if (kv->type == GGUF_TYPE_ARRAY) {
19782 if (kv->value.arr.data) {
19783 if (kv->value.arr.type == GGUF_TYPE_STRING) {
19784 for (uint32_t j = 0; j < kv->value.arr.n; ++j) {
19785 struct gguf_str * str = &((struct gguf_str *) kv->value.arr.data)[j];
19786 if (str->data) {
19787 free(str->data);
19788 }
19789 }
19790 }
19791 free(kv->value.arr.data);
19792 }
19793 }
19794 }
19795
19796 free(ctx->kv);
19797 }
19798
19799 if (ctx->infos) {
19800 for (uint32_t i = 0; i < ctx->header.n_tensors; ++i) {
19801 struct gguf_tensor_info * info = &ctx->infos[i];
19802
19803 if (info->name.data) {
19804 free(info->name.data);
19805 }
19806 }
19807
19808 free(ctx->infos);
19809 }
19810
19811 GGML_ALIGNED_FREE(ctx);
19812}
19813
19814const char * gguf_type_name(enum gguf_type type) {
19815 return GGUF_TYPE_NAME[type];

Callers 15

gguf_init_from_fileFunction · 0.70
~llama_model_loaderMethod · 0.70
export_loraFunction · 0.50
clip_freeFunction · 0.50
clip_model_quantizeFunction · 0.50
save_llama_model_ggufFunction · 0.50
save_llama_model_fileFunction · 0.50
save_checkpoint_fileFunction · 0.50
load_vocabFunction · 0.50
save_as_llama_modelFunction · 0.50
init_modelFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected