| 849 | } |
| 850 | |
| 851 | ggml_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 | |
| 879 | ggml_tensor * llm_graph_context::build_norm( |
| 880 | ggml_tensor * cur, |
nothing calls this directly
no test coverage detected