From 6bc94453f695762c86945112152ab464a534457e Mon Sep 17 00:00:00 2001 From: Charles Xu Date: Wed, 27 Aug 2025 12:14:30 +0200 Subject: [PATCH 1/2] kleidiai: fix GGML_ASSERT(*cur_backend_id != -1) failed --- ggml/src/ggml-cpu/kleidiai/kleidiai.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp b/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp index dff8fa244a1c9..a3edf1894f886 100644 --- a/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp +++ b/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp @@ -87,6 +87,15 @@ static inline int64_t ggml_ne(const ggml_tensor * tensor, int dim) { return tensor->ne[dim]; } +static inline bool is_whisper_model(const struct ggml_tensor* op) { + const int64_t n_dims = op->src[0]->ne[0]; + if (n_dims == 384 || n_dims == 512 || n_dims == 768 || + n_dims == 1024 || n_dims == 1280) { + return true; + } + return false; +} + template static Ret variant_call(const Variant & var, Args&&... args) { return std::visit([&](auto&& func) -> Ret { @@ -510,12 +519,12 @@ class extra_buffer_type : ggml::cpu::extra_buffer_type { op->src[0]->buffer && (ggml_n_dims(op->src[0]) == 2) && op->src[0]->buffer->buft == ggml_backend_cpu_kleidiai_buffer_type() && ctx.kernels) { - if (op->op == GGML_OP_GET_ROWS && op->src[1]->ne[0] != 8) { - return false; - } if (op->src[1]->buffer && !ggml_backend_buft_is_host(op->src[1]->buffer->buft)) { return false; } + if (op->op == GGML_OP_GET_ROWS) { + return is_whisper_model(op); + } if ((op->src[1]->type == GGML_TYPE_F32 || op->src[1]->type == GGML_TYPE_I32) && ggml_ne(op->src[1], 2) == 1 && ggml_ne(op->src[1], 3) == 1) { return true; From cd85c775c9d4116527a8bb8031ed66eac5d03cdb Mon Sep 17 00:00:00 2001 From: Charles Xu Date: Tue, 9 Sep 2025 11:44:59 +0200 Subject: [PATCH 2/2] removes the Whisper-specific check for GET_ROWS support --- ggml/src/ggml-cpu/kleidiai/kleidiai.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp b/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp index a3edf1894f886..6366eecdce411 100644 --- a/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp +++ b/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp @@ -87,15 +87,6 @@ static inline int64_t ggml_ne(const ggml_tensor * tensor, int dim) { return tensor->ne[dim]; } -static inline bool is_whisper_model(const struct ggml_tensor* op) { - const int64_t n_dims = op->src[0]->ne[0]; - if (n_dims == 384 || n_dims == 512 || n_dims == 768 || - n_dims == 1024 || n_dims == 1280) { - return true; - } - return false; -} - template static Ret variant_call(const Variant & var, Args&&... args) { return std::visit([&](auto&& func) -> Ret { @@ -522,9 +513,6 @@ class extra_buffer_type : ggml::cpu::extra_buffer_type { if (op->src[1]->buffer && !ggml_backend_buft_is_host(op->src[1]->buffer->buft)) { return false; } - if (op->op == GGML_OP_GET_ROWS) { - return is_whisper_model(op); - } if ((op->src[1]->type == GGML_TYPE_F32 || op->src[1]->type == GGML_TYPE_I32) && ggml_ne(op->src[1], 2) == 1 && ggml_ne(op->src[1], 3) == 1) { return true;