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

Function llava_eval_image_embed

examples/llava/llava.cpp:70–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70bool llava_eval_image_embed(llama_context * ctx_llama, const struct llava_image_embed * image_embed, int n_batch, int * n_past) {
71 int n_embd = llama_n_embd(llama_get_model(ctx_llama));
72
73 for (int i = 0; i < image_embed->n_image_pos; i += n_batch) {
74 int n_eval = image_embed->n_image_pos - i;
75 if (n_eval > n_batch) {
76 n_eval = n_batch;
77 }
78 llama_batch batch = {int32_t(n_eval), nullptr, (image_embed->embed+i*n_embd), nullptr, nullptr, nullptr, nullptr, *n_past, 1, 0, };
79 if (llama_decode(ctx_llama, batch)) {
80 fprintf(stderr, "%s : failed to eval\n", __func__);
81 return false;
82 }
83 *n_past += n_eval;
84 }
85 return true;
86}
87
88LLAVA_API struct llava_image_embed * llava_image_embed_make_with_bytes(struct clip_ctx * ctx_clip, int n_threads, const unsigned char * image_bytes, int image_bytes_length) {
89 clip_image_u8 * img = make_clip_image_u8();

Callers 1

process_promptFunction · 0.85

Calls 4

fprintfFunction · 0.85
llama_n_embdFunction · 0.50
llama_get_modelFunction · 0.50
llama_decodeFunction · 0.50

Tested by

no test coverage detected