| 812 | } |
| 813 | |
| 814 | core::TensorValue build_decoder( |
| 815 | core::ModuleBuildContext & ctx, |
| 816 | const core::TensorValue & input, |
| 817 | const VibeVoiceTokenizerDecoderWeights & weights, |
| 818 | const VibeVoiceTokenizerConfig & config, |
| 819 | core::ConstantTensorCache & constants) { |
| 820 | if (weights.stages.size() != weights.upsample_layers.size() + 1) { |
| 821 | throw std::runtime_error("VibeVoice tokenizer decoder layer/stage count mismatch"); |
| 822 | } |
| 823 | auto hidden = input; |
| 824 | for (size_t stage = 0; stage < weights.stages.size(); ++stage) { |
| 825 | if (stage == 0) { |
| 826 | hidden = sconv1d(ctx, hidden, weights.stem, 1); |
| 827 | } else { |
| 828 | hidden = sconv_transpose1d(ctx, hidden, weights.upsample_layers[stage - 1], config.decoder_ratios[stage - 1]); |
| 829 | } |
| 830 | for (const auto & block : weights.stages[stage]) { |
| 831 | hidden = tokenizer_block(ctx, hidden, block, constants, config.layernorm_eps); |
| 832 | } |
| 833 | } |
| 834 | if (weights.norm.has_value()) { |
| 835 | hidden = channel_rms_norm(ctx, hidden, *weights.norm, constants, config.layernorm_eps); |
| 836 | } |
| 837 | return sconv1d(ctx, hidden, weights.head, 1); |
| 838 | } |
| 839 | |
| 840 | core::TensorValue build_decoder_streaming( |
| 841 | core::ModuleBuildContext & ctx, |
no test coverage detected