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

Function same_feed_forward

src/models/stable_audio/same_autoencoder.cpp:278–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

276}
277
278core::TensorValue same_feed_forward(
279 core::ModuleBuildContext & ctx,
280 const core::TensorValue & input,
281 const StableAudioSameFeedForwardWeights & weights,
282 bool sinusoidal) {
283 const int64_t dim = input.shape.last_dim();
284 const int64_t inner = dim * 3;
285 auto projected = modules::LinearModule({dim, 2 * inner, true, GGML_PREC_F32}).build(ctx, input, weights.in_proj);
286 auto value = modules::SliceModule({2, 0, inner}).build(ctx, projected);
287 auto gate = modules::SliceModule({2, inner, inner}).build(ctx, projected);
288 if (sinusoidal) {
289 gate = core::wrap_tensor(ggml_sin(ctx.ggml, scale_tensor(ctx, gate, kPi).tensor), gate.shape, GGML_TYPE_F32);
290 } else {
291 gate = modules::SiluModule{}.build(ctx, gate);
292 }
293 auto hidden = modules::MulModule{}.build(ctx, value, gate);
294 return modules::LinearModule({inner, dim, true, GGML_PREC_F32}).build(ctx, hidden, weights.out_proj);
295}
296
297core::TensorValue same_transformer_layer(
298 core::ModuleBuildContext & ctx,

Callers 1

same_transformer_layerFunction · 0.85

Calls 7

LinearModuleClass · 0.85
SliceModuleClass · 0.85
wrap_tensorFunction · 0.85
ggml_sinFunction · 0.85
last_dimMethod · 0.80
scale_tensorFunction · 0.70
buildMethod · 0.45

Tested by

no test coverage detected