MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / swiglu

Function swiglu

src/models/miocodec/graph_ops.cpp:179–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179core::TensorValue swiglu(
180 core::ModuleBuildContext & ctx,
181 const core::TensorValue & input,
182 const MioCodecTransformerLayerWeights & weights,
183 int64_t dim,
184 int64_t intermediate_dim) {
185 auto gate = engine::modules::LinearModule({dim, intermediate_dim, weights.feed_forward_w1.bias.has_value()}).build(
186 ctx,
187 input,
188 weights.feed_forward_w1);
189 gate = core::wrap_tensor(ggml_silu(ctx.ggml, gate.tensor), gate.shape, GGML_TYPE_F32);
190 auto up = engine::modules::LinearModule({dim, intermediate_dim, weights.feed_forward_w3.bias.has_value()}).build(
191 ctx,
192 input,
193 weights.feed_forward_w3);
194 auto hidden = engine::modules::MulModule{}.build(ctx, gate, up);
195 return engine::modules::LinearModule({intermediate_dim, dim, weights.feed_forward_w2.bias.has_value()}).build(
196 ctx,
197 hidden,
198 weights.feed_forward_w2);
199}
200
201core::TensorValue apply_rope_fast(
202 core::ModuleBuildContext & ctx,

Callers 1

transformerFunction · 0.85

Calls 5

LinearModuleClass · 0.85
wrap_tensorFunction · 0.85
ggml_siluFunction · 0.85
ggml_mulFunction · 0.85
buildMethod · 0.45

Tested by

no test coverage detected