Helper to initialize a llama batch.
| 11 | #ifdef WASMEDGE_PLUGIN_WASI_NN_BACKEND_GGML |
| 12 | // Helper to initialize a llama batch. |
| 13 | struct llama_batch allocBatch(int64_t NTokens, int64_t Embd, |
| 14 | int32_t NSeqMax) noexcept { |
| 15 | struct llama_batch Batch = llama_batch_init( |
| 16 | /* n_tokens_alloc */ static_cast<int32_t>(NTokens), |
| 17 | /* embd */ static_cast<int32_t>(Embd), |
| 18 | /* n_seq_max */ static_cast<int32_t>(NSeqMax)); |
| 19 | std::fill(Batch.n_seq_id, Batch.n_seq_id + NTokens, |
| 20 | static_cast<int32_t>(NSeqMax)); |
| 21 | for (int64_t I = 0; I < NTokens; I++) { |
| 22 | std::fill(Batch.seq_id[I], Batch.seq_id[I] + NSeqMax, 0); |
| 23 | } |
| 24 | std::fill(Batch.logits, Batch.logits + NTokens, false); |
| 25 | return Batch; |
| 26 | } |
| 27 | |
| 28 | // Get base64 image position if found in prompt. |
| 29 | std::optional<std::tuple<size_t, size_t, size_t>> |
no outgoing calls
no test coverage detected