LLM inference in C/C++
C++ ggml
ggml : check for allocation failures to prevent crashes (#28149)
Alexey Kopytko5b335f413e4f
diff --git a/tools/mtmd/clip.cpp b/tools/mtmd/clip.cppindex cd6421def5..1783c7ddfd 100644--- a/tools/mtmd/clip.cpp+++ b/tools/mtmd/clip.cpp@@ -4436,7 +4436,10 @@ bool clip_encode(struct clip_ctx * ctx, struct clip_encode_params * params) {// build the inference graphggml_backend_sched_reset(ctx->sched.get());ggml_cgraph * gf = clip_get_graph_builder(ctx, imgs, params)->build();- ggml_backend_sched_alloc_graph(ctx->sched.get(), gf);+ if (!ggml_backend_sched_alloc_graph(ctx->sched.get(), gf)) {+ LOG_ERR("%s: failed to allocate compute graph\n", __func__);+ return false;+ }// set inputsconst auto & model = ctx->model;