From c2f79c31c1a5c9f719eb7b1650cfc9997454b4c3 Mon Sep 17 00:00:00 2001 From: yirongjie Date: Sat, 9 Nov 2024 12:44:43 +0000 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=20NPU=20affect=20CPU?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Layer.hpp | 2 +- src/backends/cpu/CPUKVCache.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Layer.hpp b/src/Layer.hpp index 752e272c..7d729b84 100644 --- a/src/Layer.hpp +++ b/src/Layer.hpp @@ -125,7 +125,7 @@ class Layer { do_init = !inited_loaded; if (op_ == nullptr) { #ifdef USE_QNN - if (param_["type"] == KVCACHE || param_["type"] == KVCACHENPU) { + if ((param_["type"] == KVCACHE || param_["type"] == KVCACHENPU) && (Backend::global_backends.find(MLLM_QNN) != Backend::global_backends.end())) { if (kv_cache_map.find(name_) == kv_cache_map.end()) { // for the prefill part, we need to create a new op param_["type"] = KVCACHENPU; diff --git a/src/backends/cpu/CPUKVCache.cpp b/src/backends/cpu/CPUKVCache.cpp index 204648ab..c487a04a 100644 --- a/src/backends/cpu/CPUKVCache.cpp +++ b/src/backends/cpu/CPUKVCache.cpp @@ -5,9 +5,9 @@ #include "Types.hpp" int n_pack = 16; -#ifndef USE_QNN +// #ifndef USE_QNN #define KVCache_TYPE_16 -#endif +// #endif namespace mllm { CPUKVCache::CPUKVCache(Backend *bn, string opName, int n_rep, int cache_max, int threadCount) : thread_count(threadCount), Op(bn, opName) {