MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / build_graph_lora

Function build_graph_lora

examples/export-lora/export-lora.cpp:303–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301
302
303static struct ggml_cgraph * build_graph_lora(
304 struct ggml_context * ctx,
305 struct ggml_tensor * tensor,
306 struct ggml_tensor * lora_a,
307 struct ggml_tensor * lora_b,
308 float scaling
309) {
310 struct ggml_tensor * ab = ggml_mul_mat(ctx, lora_a, lora_b);
311 if (scaling != 1.0f) {
312 ab = ggml_scale(ctx, ab, ggml_new_f32(ctx, scaling));
313 }
314 struct ggml_tensor * res = ggml_add_inplace(ctx, tensor, ab);
315
316 struct ggml_cgraph * gf = ggml_new_graph(ctx);
317 ggml_build_forward_expand (gf, res);
318 return gf;
319}
320
321static bool apply_lora(struct ggml_tensor * tensor, struct lora_data * lora, int n_threads) {
322 if (lora->ctx == NULL) {

Callers 1

apply_loraFunction · 0.85

Calls 6

ggml_mul_matFunction · 0.50
ggml_scaleFunction · 0.50
ggml_new_f32Function · 0.50
ggml_add_inplaceFunction · 0.50
ggml_new_graphFunction · 0.50

Tested by

no test coverage detected