MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / allocBatch

Function allocBatch

plugins/wasi_nn/GGML/utils.cpp:13–26  ·  view source on GitHub ↗

Helper to initialize a llama batch.

Source from the content-addressed store, hash-verified

11#ifdef WASMEDGE_PLUGIN_WASI_NN_BACKEND_GGML
12// Helper to initialize a llama batch.
13struct 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.
29std::optional<std::tuple<size_t, size_t, size_t>>

Callers 2

setInputFunction · 0.50
initExecCtxFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected