bench : fix timings by running a pre-heat

This commit is contained in:
Georgi Gerganov
2023-09-13 23:02:33 +03:00
parent d863f725a1
commit f408c64564
3 changed files with 12 additions and 3 deletions

View File

@ -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;

View File

@ -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)

View File

@ -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;
}
}