diff options
author | xaedes <xaedes@googlemail.com> | 2023-04-21 17:25:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-21 18:25:21 +0300 |
commit | 8687c1f2581d059cd5b6a9502f89bd343566062a (patch) | |
tree | 5ca514c6ba556e82992d26cae9083e9752bf00dc | |
parent | 1bfc153e2f35ddd9d64b084e8d1a5e6fa57ad1c9 (diff) |
llama : remember and restore kv cache data pointers (#1104)
because their value is stored in buf and overwritten by memcpy
-rw-r--r-- | llama.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -2092,7 +2092,11 @@ void llama_set_kv_cache( int n_token_count) { // Make sure we have the same kv cache setup LLAMA_ASSERT(ctx->model.kv_self.buf.size == n_size); + void * k_data = ctx->model.kv_self.k->data; // remember data pointers + void * v_data = ctx->model.kv_self.v->data; // because their value is stored in buf and overwritten by memcpy memcpy(ctx->model.kv_self.buf.addr, kv_cache, n_size); + ctx->model.kv_self.k->data = k_data; // restore correct data pointers + ctx->model.kv_self.v->data = v_data; ctx->model.kv_self.n = n_token_count; } |