From 216e7d96481767f1f766ecbe6490ef0e8cf9ebbe Mon Sep 17 00:00:00 2001 From: Jia Liu Date: Thu, 19 Sep 2024 11:30:47 +0800 Subject: [PATCH] fix llama_reset_model_time --- examples/llama-bench/llama-bench.cpp | 3 ++- include/llama.h | 2 +- src/llama.cpp | 9 ++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/llama-bench/llama-bench.cpp b/examples/llama-bench/llama-bench.cpp index 31a9213ea..a20515411 100644 --- a/examples/llama-bench/llama-bench.cpp +++ b/examples/llama-bench/llama-bench.cpp @@ -1558,7 +1558,8 @@ int main(int argc, char ** argv) { } prev_inst = &inst; } else { - llama_model_reset_time(lmodel); + // ensure load_time dost not accumulate in llama_bench when not loading the same model + llama_reset_model_time(lmodel); } llama_context * ctx = llama_new_context_with_model(lmodel, inst.to_llama_cparams()); diff --git a/include/llama.h b/include/llama.h index c8ce495af..616b52310 100644 --- a/include/llama.h +++ b/include/llama.h @@ -414,7 +414,7 @@ extern "C" { const char * path_model, struct llama_model_params params); - LLAMA_API void llama_model_reset_time(struct llama_model * model); + LLAMA_API void llama_reset_model_time(struct llama_model * model); LLAMA_API void llama_free_model(struct llama_model * model); diff --git a/src/llama.cpp b/src/llama.cpp index 1dda8210a..d4f737626 100644 --- a/src/llama.cpp +++ b/src/llama.cpp @@ -8809,11 +8809,6 @@ static bool llm_load_tensors( return true; } -void llama_model_reset_time(llama_model * model) { - model->t_start_us = ggml_time_us(); - model->t_load_us = ggml_time_us() - model->t_start_us; -} - // Returns 0 on success, -1 on error, and -2 on cancellation via llama_progress_callback static int llama_model_load(const std::string & fname, llama_model & model, llama_model_params & params) { model.t_start_us = ggml_time_us(); @@ -18695,6 +18690,10 @@ struct llama_model * llama_load_model_from_file( return model; } +void llama_reset_model_time(llama_model * model) { + model->t_start_us = ggml_time_us() - model->t_load_us; +} + void llama_free_model(struct llama_model * model) { delete model; }