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

Function build_encoder

src/models/vibevoice/tokenizer_audio.cpp:766–788  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

764}
765
766core::TensorValue build_encoder(
767 core::ModuleBuildContext & ctx,
768 const core::TensorValue & input,
769 const VibeVoiceTokenizerEncoderWeights & weights,
770 const VibeVoiceTokenizerConfig & config,
771 core::ConstantTensorCache & constants) {
772 if (weights.downsample_layers.size() != weights.stages.size()) {
773 throw std::runtime_error("VibeVoice tokenizer encoder layer/stage count mismatch");
774 }
775 auto hidden = input;
776 for (size_t stage = 0; stage < weights.stages.size(); ++stage) {
777 const int64_t stride = stage == 0 ? 1 : config.encoder_ratios[config.encoder_ratios.size() - stage];
778 hidden = sconv1d(ctx, hidden, weights.downsample_layers[stage], stride);
779 for (const auto & block : weights.stages[stage]) {
780 hidden = tokenizer_block(ctx, hidden, block, constants, config.layernorm_eps);
781 }
782 }
783 if (weights.norm.has_value()) {
784 hidden = channel_rms_norm(ctx, hidden, *weights.norm, constants, config.layernorm_eps);
785 }
786 hidden = sconv1d(ctx, hidden, weights.head, 1);
787 return hidden;
788}
789
790core::TensorValue build_encoder_streaming(
791 core::ModuleBuildContext & ctx,

Callers 2

ensure_encoder_graphMethod · 0.85

Calls 4

sconv1dFunction · 0.85
tokenizer_blockFunction · 0.85
channel_rms_normFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected