Skip to content

Commit 0726f99

Browse files
dm40yi0
authored andcommitted
[WASI-NN] ggml: add the warmup option
Signed-off-by: dm4 <dm4@secondstate.io>
1 parent 1f9b873 commit 0726f99

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

wasi_nn/wasinn_ggml.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Expect<ErrNo> parseMetadata(Graph &GraphRef, const std::string &Metadata,
7979
// main-gpu: int64_t
8080
// tensor-split: string, comma-separated floating number list
8181
// use-mmap: use mmap
82+
// warmup: bool
8283
// Context parameters (used by the llama context):
8384
// ctx-size: uint64_t
8485
// batch-size: uint64_t
@@ -226,6 +227,14 @@ Expect<ErrNo> parseMetadata(Graph &GraphRef, const std::string &Metadata,
226227
return ErrNo::InvalidArgument;
227228
}
228229
}
230+
if (Doc.at_key("warmup").error() == simdjson::SUCCESS) {
231+
auto Err = Doc["warmup"].get<bool>().get(GraphRef.WarmUp);
232+
if (Err) {
233+
spdlog::error(
234+
"[WASI-NN] GGML backend: Unable to retrieve the warmup option."sv);
235+
return ErrNo::InvalidArgument;
236+
}
237+
}
229238

230239
// The context parameters.
231240
if (Doc.at_key("ctx-size").error() == simdjson::SUCCESS) {
@@ -341,6 +350,7 @@ Expect<ErrNo> setupParams(Graph &GraphRef, common_params &Params) {
341350
Params.n_ctx = static_cast<uint32_t>(GraphRef.CtxSize);
342351
Params.n_batch = static_cast<uint32_t>(GraphRef.BatchSize);
343352
Params.n_ubatch = static_cast<uint32_t>(GraphRef.UBatchSize);
353+
Params.warmup = GraphRef.WarmUp;
344354
Params.cpuparams.n_threads = static_cast<uint32_t>(GraphRef.Threads);
345355
Params.cpuparams_batch.n_threads = static_cast<uint32_t>(GraphRef.Threads);
346356
Params.embedding = GraphRef.Embedding;

wasi_nn/wasinn_ggml.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ struct Graph {
4040
int64_t NGPULayers = 0;
4141
std::vector<float> TensorSplit;
4242
bool UseMMap = true;
43+
bool WarmUp = true;
4344
// Context parameters:
4445
uint64_t CtxSize;
4546
uint64_t BatchSize;

0 commit comments

Comments
 (0)