From 0ef2e5e4d47c1eeb65b00ee9af9ffbd07993760b Mon Sep 17 00:00:00 2001 From: "Yu, Zijun" Date: Thu, 11 Dec 2025 11:30:25 +0800 Subject: [PATCH] Fix decoder can_reuse for llama-bench --- ggml/src/ggml-openvino/ggml-decoder.h | 12 ++++++------ ggml/src/ggml-openvino/utils.cpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ggml/src/ggml-openvino/ggml-decoder.h b/ggml/src/ggml-openvino/ggml-decoder.h index bcfe8097d6..edcd036785 100644 --- a/ggml/src/ggml-openvino/ggml-decoder.h +++ b/ggml/src/ggml-openvino/ggml-decoder.h @@ -25,15 +25,15 @@ struct ModelParams { // std::vector kv_names; - bool can_reuse_dynamically(const ModelParams & other) const { + bool operator==(const ModelParams & other) const { return n_seq == other.n_seq && n_heads == other.n_heads && n_heads_kv == other.n_heads_kv && - head_size == other.head_size && rope_params == other.rope_params && swa_layers == other.swa_layers; + head_size == other.head_size && rope_params == other.rope_params && swa_layers == other.swa_layers && + ctx_per_seq == other.ctx_per_seq && ctx_per_seq_swa == other.ctx_per_seq_swa; } - bool can_reuse_statically(const ModelParams & other) const { - return can_reuse_dynamically(other) && ctx_per_seq == other.ctx_per_seq && - ctx_per_seq_swa == other.ctx_per_seq_swa; - } + bool can_reuse_dynamically(const ModelParams & other) const { return *this == other; } + + bool can_reuse_statically(const ModelParams & other) const { return *this == other; } }; struct ComputeParams { diff --git a/ggml/src/ggml-openvino/utils.cpp b/ggml/src/ggml-openvino/utils.cpp index 7412dcc2a8..836e366fd7 100644 --- a/ggml/src/ggml-openvino/utils.cpp +++ b/ggml/src/ggml-openvino/utils.cpp @@ -97,7 +97,7 @@ enum ggml_status ov_graph_compute_dynamic(ggml_cgraph * cgraph, const std::strin cache_hit = it != decoder_cache.end(); if (cache_hit) { ggml_decoder = it->second; - cache_hit = ggml_decoder->get_model_params().can_reuse_statically(m_params); + cache_hit = ggml_decoder->get_model_params().can_reuse_dynamically(m_params); } if (cache_hit) {