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

Method build_lora_mm_id

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

Source from the content-addressed store, hash-verified

849}
850
851ggml_tensor * llm_graph_context::build_lora_mm_id(
852 ggml_tensor * w, // ggml_tensor * as
853 ggml_tensor * cur, // ggml_tensor * b
854 ggml_tensor * ids) const {
855 ggml_tensor * res = ggml_mul_mat_id(ctx0, w, cur, ids);
856 for (const auto & lora : *loras) {
857 llama_adapter_lora_weight * lw = lora.first->get_weight(w);
858 if (lw == nullptr) {
859 continue;
860 }
861
862 const float alpha = lora.first->alpha;
863 const float rank = (float) lw->b->ne[0];
864 const float scale = alpha ? lora.second * alpha / rank : lora.second;
865
866 ggml_tensor * ab_cur = ggml_mul_mat_id(
867 ctx0, lw->b,
868 ggml_mul_mat_id(ctx0, lw->a, cur, ids),
869 ids
870 );
871
872 ab_cur = ggml_scale(ctx0, ab_cur, scale);
873 res = ggml_add(ctx0, res, ab_cur);
874 }
875
876 return res;
877}
878
879ggml_tensor * llm_graph_context::build_norm(
880 ggml_tensor * cur,

Callers

nothing calls this directly

Calls 4

ggml_mul_mat_idFunction · 0.85
ggml_scaleFunction · 0.85
ggml_addFunction · 0.85
get_weightMethod · 0.45

Tested by

no test coverage detected