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

Function build_attn_inp_k_impl

subprojects/llama.cpp/src/llama-graph.cpp:1889–1914  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1887}
1888
1889static std::unique_ptr<llm_graph_input_attn_k> build_attn_inp_k_impl(
1890 ggml_context * ctx0,
1891 const llama_ubatch & ubatch,
1892 const llama_hparams & hparams,
1893 const llama_cparams & cparams,
1894 const llama_kv_cache_context * mctx_cur) {
1895
1896 auto inp = std::make_unique<llm_graph_input_attn_k>(hparams, cparams, mctx_cur);
1897
1898 {
1899 GGML_ASSERT(hparams.swa_type == LLAMA_SWA_TYPE_NONE && "Use llama_kv_cache_iswa for SWA");
1900
1901 const auto n_kv = mctx_cur->get_n_kv();
1902 const auto n_tokens = ubatch.n_tokens;
1903 const auto n_stream = cparams.kv_unified ? 1 : ubatch.n_seqs_unq;
1904
1905 inp->self_k_idxs = mctx_cur->build_input_k_idxs(ctx0, ubatch);
1906
1907 inp->self_kq_mask = ggml_new_tensor_4d(ctx0, GGML_TYPE_F32, n_kv, n_tokens/n_stream, 1, n_stream);
1908 ggml_set_input(inp->self_kq_mask);
1909
1910 inp->self_kq_mask_cnv = cparams.flash_attn ? ggml_cast(ctx0, inp->self_kq_mask, GGML_TYPE_F16) : inp->self_kq_mask;
1911 }
1912
1913 return inp;
1914}
1915
1916llm_graph_input_attn_k * llm_graph_context::build_attn_inp_k() const {
1917 const auto * mctx_cur = static_cast<const llama_kv_cache_context *>(mctx);

Callers 1

build_attn_inp_kMethod · 0.85

Calls 5

ggml_new_tensor_4dFunction · 0.85
ggml_set_inputFunction · 0.85
ggml_castFunction · 0.85
get_n_kvMethod · 0.80
build_input_k_idxsMethod · 0.80

Tested by

no test coverage detected