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

Function scalar_decoder

src/models/heartmula/codec.cpp:650–707  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

648 config.res_kernel_size,
649 dilations[residual]);
650 }
651 channels = out_channels;
652 }
653 if (config.num_samples > 1) {
654 x = adjacent_repeat_frames_bct(ctx, x, config.num_samples);
655 x = causal_conv1d(
656 ctx,
657 x,
658 weights.post_processor.conv,
659 config.init_channel,
660 config.init_channel,
661 config.default_kernel_size);
662 x = prelu(ctx, x, weights.post_processor.activation);
663 }
664 return causal_conv1d(
665 ctx,
666 x,
667 weights.output_conv,
668 config.init_channel,
669 config.num_bands,
670 config.default_kernel_size);
671}
672
673core::TensorValue expand_batch_token(
674 core::ModuleBuildContext & ctx,
675 const core::TensorValue & input_bd,
676 int64_t tokens,
677 int64_t dim) {
678 const int64_t batch = input_bd.shape.dims[0];
679 const auto view = core::reshape_tensor(ctx, core::ensure_backend_addressable_layout(ctx, input_bd), core::TensorShape::from_dims({batch, 1, dim}));
680 return modules::RepeatModule({core::TensorShape::from_dims({batch, tokens, dim})}).build(ctx, view);
681}
682
683core::TensorValue project_layer(
684 core::ModuleBuildContext & ctx,
685 const core::TensorValue & input_btc,
686 const HeartCodecProjectLayerWeights & weights,
687 int64_t in_channels,
688 int64_t out_channels) {
689 auto x = modules::TransposeModule({{0, 2, 1}, 3}).build(ctx, input_btc);
690 x = modules::Conv1dModule({in_channels, out_channels, 3, 1, 1, 1, true}).build(ctx, x, weights.ffn_1);
691 x = scale(ctx, x, kProjectLayerScale);
692 x = modules::TransposeModule({{0, 2, 1}, 3}).build(ctx, x);
693 return modules::LinearModule({out_channels, out_channels, true, GGML_PREC_F32}).build(ctx, x, weights.ffn_2);
694}
695
696core::TensorValue timestep_embedding(
697 core::ModuleBuildContext & ctx,
698 const core::TensorValue & timesteps,
699 const core::TensorValue & freqs) {
700 const int64_t batch = timesteps.shape.dims[0];
701 auto t = core::reshape_tensor(ctx, timesteps, core::TensorShape::from_dims({batch, 1}));
702 t = modules::RepeatModule({core::TensorShape::from_dims({batch, 256})}).build(ctx, t);
703 auto f = modules::RepeatModule({core::TensorShape::from_dims({batch, 256})}).build(ctx, freqs);
704 auto args = scale(ctx, modules::MulModule{}.build(ctx, t, f), kFlowTimestepScale);
705 auto cos_part = core::wrap_tensor(ggml_cos(ctx.ggml, core::ensure_backend_addressable_layout(ctx, args).tensor), args.shape, GGML_TYPE_F32);
706 auto sin_part = core::wrap_tensor(ggml_sin(ctx.ggml, args.tensor), args.shape, GGML_TYPE_F32);
707 return modules::ConcatModule({1}).build(ctx, cos_part, sin_part);

Callers 1

Calls 10

quantize_scalar_latentFunction · 0.85
Conv1dModuleClass · 0.85
scalar_residual_unitFunction · 0.85
preluFunction · 0.85
pow2_i64Function · 0.70
causal_conv_transpose1dFunction · 0.70
causal_conv1dFunction · 0.70
sizeMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected