mirror of
https://github.com/ikawrakow/ik_llama.cpp.git
synced 2026-04-30 11:21:56 +00:00
Avoid rebuild of GGML graph for each token (#98)
Introduces caching of GGML graph to avoid unnecessary full rebuild between each token. KV cache parameters, which change with each token, are updated directly in cached GGML graph. Can be disabled with GGML_DISABLE_GRAPH_CACHING environment variable.
This commit is contained in:
@@ -232,6 +232,12 @@ extern "C" {
|
||||
GGML_API void ggml_backend_tensor_alloc(ggml_backend_buffer_t buffer, struct ggml_tensor * tensor, void * addr);
|
||||
GGML_API void ggml_backend_view_init(struct ggml_tensor * tensor);
|
||||
|
||||
// Utility to query whether cached GGML graph is in use
|
||||
GGML_API bool ggml_use_cached_graph(ggml_backend_sched_t sched);
|
||||
|
||||
// Set whether or not to use GGML graph caching
|
||||
GGML_API void ggml_set_cached_graph(ggml_backend_sched_t sched, bool set_value);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -597,6 +597,13 @@ extern "C" {
|
||||
GGML_TENSOR_FLAG_PARAM = 4,
|
||||
};
|
||||
|
||||
// Flag (used on GGML_OP_CPY nodes) on whether node is associated with K or V cache
|
||||
enum ggml_kv_cache_flag {
|
||||
GGML_KV_CACHE_FLAG_NONE = 0,
|
||||
GGML_KV_CACHE_FLAG_K = 1,
|
||||
GGML_KV_CACHE_FLAG_V = 2
|
||||
};
|
||||
|
||||
// ggml object
|
||||
struct ggml_object {
|
||||
size_t offs;
|
||||
|
||||
Reference in New Issue
Block a user