perf: use fused ggml_geglu_swapped for GEGLU (#2245)

This commit is contained in:
Daniele authored and GitHub committed 2026-10-29 23:18:10 +08:00
1 parent 77b72a2efe
commit 8ee08e3cb9
1 file changed
+4 -8
+4 -8
View File
@@ -198,15 +198,11 @@ public:
auto proj = std::dynamic_pointer_cast<Linear>(blocks["proj"]); auto proj = std::dynamic_pointer_cast<Linear>(blocks["proj"]);
x = proj->forward(ctx, x); // [ne3, ne2, ne1, dim_out*2] x = proj->forward(ctx, x); // [ne3, ne2, ne1, dim_out*2]
auto x_vec = ggml_ext_chunk(ctx->ggml_ctx, x, 2, 0, false);
x = x_vec[0]; // [ne3, ne2, ne1, dim_out]
auto gate = x_vec[1]; // [ne3, ne2, ne1, dim_out]
gate = ggml_cont(ctx->ggml_ctx, gate); if (!ggml_is_contiguous_1(x)) {
x = ggml_cont(ctx->ggml_ctx, x);
gate = ggml_ext_gelu(ctx->ggml_ctx, gate, true); }
x = ggml_geglu_swapped(ctx->ggml_ctx, x); // [ne3, ne2, ne1, dim_out]
x = ggml_mul(ctx->ggml_ctx, x, gate); // [ne3, ne2, ne1, dim_out]
return x; return x;
} }