mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-11-12 03:49:09 +00:00
refactor: replace manual gated activations with native ggml GLU (#2250)
This commit is contained in:
1 parent
37bc88b5e9
commit
e239e4b0fd
13 files changed
+33
-53
No files matched your search
@@ -134,8 +134,8 @@ namespace MiniMaxH3 {
|
||||
auto w1 = std::dynamic_pointer_cast<Linear>(blocks["w1"]);
|
||||
auto w2 = std::dynamic_pointer_cast<Linear>(blocks["w2"]);
|
||||
x = norm->forward(ctx, x);
|
||||
auto gate = ggml_ext_gelu(ctx->ggml_ctx, w0->forward(ctx, x), true);
|
||||
return w2->forward(ctx, ggml_mul(ctx->ggml_ctx, gate, w1->forward(ctx, x)));
|
||||
auto gate = w0->forward(ctx, x);
|
||||
return w2->forward(ctx, ggml_geglu_split(ctx->ggml_ctx, gate, w1->forward(ctx, x)));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -316,11 +316,8 @@ namespace MiniMaxH3VAE {
|
||||
ggml_tensor* forward(GGMLRunnerContext* ctx, ggml_tensor* x) {
|
||||
auto w1 = std::dynamic_pointer_cast<Linear>(blocks["w1"]);
|
||||
auto w2 = std::dynamic_pointer_cast<Linear>(blocks["w2"]);
|
||||
auto gate = ggml_ext_chunk(ctx->ggml_ctx, w1->forward(ctx, x), 2, 0);
|
||||
return w2->forward(ctx,
|
||||
ggml_mul(ctx->ggml_ctx,
|
||||
ggml_silu(ctx->ggml_ctx, gate[0]),
|
||||
gate[1]));
|
||||
auto gate = ggml_swiglu(ctx->ggml_ctx, w1->forward(ctx, x));
|
||||
return w2->forward(ctx, gate);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user