| 68 | } |
| 69 | |
| 70 | bool 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 | |
| 88 | LLAVA_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(); |
no test coverage detected