@@ -613,6 +613,28 @@ ggml_tensor * llm_graph_context::build_ffn(
613
613
cur = ggml_reglu (ctx0, cur);
614
614
cb (cur, " ffn_reglu" , il);
615
615
} break ;
616
+ case LLM_FFN_GEGLU:
617
+ {
618
+ // Split into two equal parts
619
+ int64_t split_point = cur->ne [0 ] / 2 ;
620
+ ggml_tensor * output_ffn_up = ggml_cont (ctx0, ggml_view_2d (
621
+ ctx0, cur, split_point,
622
+ cur->ne [1 ], cur->nb [1 ], 0
623
+ ));
624
+ ggml_tensor * output_ffn_gate = ggml_cont (ctx0, ggml_view_2d (
625
+ ctx0, cur, split_point,
626
+ cur->ne [1 ], cur->nb [1 ],
627
+ split_point * ggml_element_size (cur)
628
+ ));
629
+
630
+ // Apply GELU activation function to the first part
631
+ output_ffn_up = ggml_gelu (ctx0, output_ffn_up);
632
+ cb (output_ffn_up, " ffn_gelu" , il);
633
+
634
+ // Element-wise multiplication between the activated part and the gate part
635
+ cur = ggml_mul (ctx0, output_ffn_up, output_ffn_gate);
636
+ cb (cur, " ffn_geglu" , il);
637
+ } break ;
616
638
}
617
639
618
640
if (gate && type_gate == LLM_FFN_PAR) {
0 commit comments