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

Method build_attn_inp_no_cache

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

Source from the content-addressed store, hash-verified

1722}
1723
1724llm_graph_input_attn_no_cache * llm_graph_context::build_attn_inp_no_cache() const {
1725 auto inp = std::make_unique<llm_graph_input_attn_no_cache>(hparams, cparams);
1726
1727 // note: there is no KV cache, so the number of KV values is equal to the number of tokens in the batch
1728 inp->self_kq_mask = ggml_new_tensor_4d(ctx0, GGML_TYPE_F32, n_tokens, n_tokens, 1, 1);
1729 ggml_set_input(inp->self_kq_mask);
1730
1731 inp->self_kq_mask_cnv = cparams.flash_attn ? ggml_cast(ctx0, inp->self_kq_mask, GGML_TYPE_F16) : inp->self_kq_mask;
1732
1733 if (hparams.swa_type != LLAMA_SWA_TYPE_NONE) {
1734 inp->self_kq_mask_swa = ggml_new_tensor_4d(ctx0, GGML_TYPE_F32, n_tokens, n_tokens, 1, 1);
1735 ggml_set_input(inp->self_kq_mask_swa);
1736
1737 inp->self_kq_mask_swa_cnv = cparams.flash_attn ? ggml_cast(ctx0, inp->self_kq_mask_swa, GGML_TYPE_F16) : inp->self_kq_mask_swa;
1738 } else {
1739 inp->self_kq_mask_swa = nullptr;
1740 inp->self_kq_mask_swa_cnv = nullptr;
1741 }
1742
1743 return (llm_graph_input_attn_no_cache *) res->add_input(std::move(inp));
1744}
1745
1746ggml_tensor * llm_graph_context::build_attn(
1747 llm_graph_input_attn_no_cache * inp,

Callers

nothing calls this directly

Calls 4

ggml_new_tensor_4dFunction · 0.85
ggml_set_inputFunction · 0.85
ggml_castFunction · 0.85
add_inputMethod · 0.80

Tested by

no test coverage detected