From f408c64564edf2ba6fe30ae94ed71db6289d430a Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Wed, 13 Sep 2023 23:02:33 +0300 Subject: [PATCH] bench : fix timings by running a pre-heat --- examples/bench/bench.cpp | 9 +++++++++ extra/bench-all.sh | 3 --- whisper.cpp | 3 +++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/examples/bench/bench.cpp b/examples/bench/bench.cpp index 49daaa01..32aa3cfd 100644 --- a/examples/bench/bench.cpp +++ b/examples/bench/bench.cpp @@ -70,6 +70,15 @@ int whisper_bench_encoder(const whisper_params & params) { return 3; } + // heat up + if (int ret = whisper_encode(ctx, 0, params.n_threads) != 0) { + fprintf(stderr, "error: failed to encode model: %d\n", ret); + return 4; + } + + whisper_reset_timings(ctx); + + // actual run if (int ret = whisper_encode(ctx, 0, params.n_threads) != 0) { fprintf(stderr, "error: failed to encode model: %d\n", ret); return 4; diff --git a/extra/bench-all.sh b/extra/bench-all.sh index 43f989db..772d55a7 100755 --- a/extra/bench-all.sh +++ b/extra/bench-all.sh @@ -48,9 +48,6 @@ printf "| CPU | OS | Config | Model | Th | Load | Enc. | Commit |\n" printf "| --- | -- | ------ | ----- | -- | ---- | ---- | ------ |\n" for model in "${models[@]}"; do - # run once to heat-up the cache - ./bench -m ./models/ggml-$model.bin -t $n_threads 2>/dev/null 1>/dev/null - # actual run # store stderr output in a variable in order to parse it later output=$(./bench -m ./models/ggml-$model.bin -t $n_threads 2>&1) diff --git a/whisper.cpp b/whisper.cpp index dbb1abae..4db95a61 100644 --- a/whisper.cpp +++ b/whisper.cpp @@ -3588,6 +3588,9 @@ void whisper_reset_timings(struct whisper_context * ctx) { ctx->state->t_sample_us = 0; ctx->state->t_encode_us = 0; ctx->state->t_decode_us = 0; + ctx->state->n_sample = 0; + ctx->state->n_encode = 0; + ctx->state->n_decode = 0; } }