| 764 | } |
| 765 | |
| 766 | core::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 | |
| 790 | core::TensorValue build_encoder_streaming( |
| 791 | core::ModuleBuildContext & ctx, |
no test coverage detected