MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / get_k

Method get_k

subprojects/llama.cpp/src/llama-kv-cache.cpp:1016–1034  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1014}
1015
1016ggml_tensor * llama_kv_cache::get_k(ggml_context * ctx, int32_t il, uint32_t n_kv, const slot_info & sinfo) const {
1017 const int32_t ikv = map_layer_ids.at(il);
1018
1019 auto * k = layers[ikv].k;
1020
1021 const uint64_t kv_size = get_size();
1022 const uint64_t n_embd_k_gqa = k->ne[0];
1023
1024 assert(n_embd_k_gqa == hparams.n_embd_k_gqa(il));
1025
1026 const uint32_t ns = sinfo.s1 - sinfo.s0 + 1;
1027
1028 return ggml_view_4d(ctx, k,
1029 hparams.n_embd_head_k, hparams.n_head_kv(il), n_kv, ns,
1030 ggml_row_size(k->type, hparams.n_embd_head_k),
1031 ggml_row_size(k->type, n_embd_k_gqa),
1032 ggml_row_size(k->type, n_embd_k_gqa*kv_size),
1033 ggml_row_size(k->type, n_embd_k_gqa*kv_size)*sinfo.s0);
1034}
1035
1036ggml_tensor * llama_kv_cache::get_v(ggml_context * ctx, int32_t il, uint32_t n_kv, const slot_info & sinfo) const {
1037 const int32_t ikv = map_layer_ids.at(il);

Callers 1

build_attnMethod · 0.80

Calls 5

ggml_view_4dFunction · 0.85
ggml_row_sizeFunction · 0.85
n_embd_k_gqaMethod · 0.80
n_head_kvMethod · 0.80
atMethod · 0.65

Tested by

no test coverage detected