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

Function llava_init

examples/llava/llava-cli.cpp:233–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231
232
233static struct llava_context * llava_init(gpt_params * params) {
234 const char * clip_path = params->mmproj.c_str();
235
236 auto prompt = params->prompt;
237 if (prompt.empty()) {
238 prompt = "describe the image in detail.";
239 }
240
241 auto ctx_clip = clip_model_load(clip_path, /*verbosity=*/ 1);
242
243 llama_backend_init(params->numa);
244
245 llama_model_params model_params = llama_model_params_from_gpt_params(*params);
246
247 llama_model * model = llama_load_model_from_file(params->model.c_str(), model_params);
248 if (model == NULL) {
249 fprintf(stderr , "%s: error: unable to load model\n" , __func__);
250 return NULL;
251 }
252
253 llama_context_params ctx_params = llama_context_params_from_gpt_params(*params);
254 ctx_params.n_ctx = params->n_ctx < 2048 ? 2048 : params->n_ctx; // we need a longer context size to process image embeddings
255
256 llama_context * ctx_llama = llama_new_context_with_model(model, ctx_params);
257
258 if (ctx_llama == NULL) {
259 fprintf(stderr , "%s: error: failed to create the llama_context\n" , __func__);
260 return NULL;
261 }
262
263 auto ctx_llava = (struct llava_context *)malloc(sizeof(llava_context));
264
265 ctx_llava->ctx_llama = ctx_llama;
266 ctx_llava->ctx_clip = ctx_clip;
267 ctx_llava->model = model;
268 return ctx_llava;
269}
270
271static void llava_free(struct llava_context * ctx_llava) {
272 if (ctx_llava->ctx_clip) {

Callers 1

mainFunction · 0.85

Calls 9

clip_model_loadFunction · 0.85
fprintfFunction · 0.85
llama_backend_initFunction · 0.50
c_strMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected