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

Function build_snake1d_exact_bct

src/models/ace_step/vae_decoder.cpp:196–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196core::TensorValue build_snake1d_exact_bct(
197 core::ModuleBuildContext & ctx,
198 const core::TensorValue & input,
199 const SnakeExactWeights & weights,
200 int64_t channels) {
201 const auto input_f32 = ensure_f32(ctx, ensure_contiguous_nontransposed(ctx, input));
202 auto alpha = ensure_f32(ctx, weights.alpha);
203 auto beta_inv = ensure_f32(ctx, weights.beta_inv);
204 if (alpha.shape.rank != 3 || alpha.shape.dims[0] != 1 || alpha.shape.dims[1] != channels || alpha.shape.dims[2] != 1 ||
205 beta_inv.shape.rank != 3 || beta_inv.shape.dims[0] != 1 || beta_inv.shape.dims[1] != channels || beta_inv.shape.dims[2] != 1) {
206 throw std::runtime_error("ACE-Step VAE Snake1d weight shape mismatch");
207 }
208 if (input_f32.shape.rank != 3) {
209 throw std::runtime_error("ACE-Step VAE Snake1d expects rank-3 BCT input");
210 }
211 auto periodic = core::wrap_tensor(
212 ggml_sqr(ctx.ggml, ggml_sin(ctx.ggml, ggml_mul(ctx.ggml, input_f32.tensor, alpha.tensor))),
213 input_f32.shape,
214 GGML_TYPE_F32);
215 const auto beta_inv_broadcast = core::wrap_tensor(
216 ggml_repeat(ctx.ggml, beta_inv.tensor, input_f32.tensor),
217 input_f32.shape,
218 GGML_TYPE_F32);
219 auto frac = modules::MulModule{}.build(ctx, periodic, beta_inv_broadcast);
220 return modules::AddModule{}.build(ctx, input_f32, frac);
221}
222
223SnakeExactWeights load_snake_exact(
224 core::BackendWeightStore & store,

Callers 4

build_residual_unitFunction · 0.85
buildMethod · 0.85
build_encoder_blockFunction · 0.85
buildMethod · 0.85

Calls 8

wrap_tensorFunction · 0.85
ggml_sqrFunction · 0.85
ggml_sinFunction · 0.85
ggml_mulFunction · 0.85
ggml_repeatFunction · 0.85
ensure_f32Function · 0.70
buildMethod · 0.45

Tested by

no test coverage detected