| 844 | GGML_PREC_F32, |
| 845 | }).build(ctx, hidden, weights.encoder.output); |
| 846 | } |
| 847 | |
| 848 | engine::core::TensorValue build_l2_normalized_rows( |
| 849 | engine::core::ModuleBuildContext & ctx, |
| 850 | const engine::core::TensorValue & input) { |
| 851 | auto contiguous = engine::core::ensure_backend_addressable_layout(ctx, input); |
| 852 | auto squared = engine::modules::MulModule{}.build(ctx, contiguous, contiguous); |
| 853 | auto summed = engine::modules::ReduceSumModule({1}).build(ctx, squared); |
| 854 | auto norm = engine::core::wrap_tensor( |
| 855 | ggml_sqrt(ctx.ggml, ggml_scale_bias(ctx.ggml, summed.tensor, 1.0F, 1.0e-20F)), |
| 856 | summed.shape, |
| 857 | GGML_TYPE_F32); |
| 858 | auto repeated_norm = engine::modules::RepeatModule({contiguous.shape}).build(ctx, norm); |
| 859 | return engine::core::wrap_tensor( |
| 860 | ggml_div(ctx.ggml, contiguous.tensor, repeated_norm.tensor), |
| 861 | contiguous.shape, |
| 862 | GGML_TYPE_F32); |
| 863 | } |
| 864 | |
| 865 | engine::core::TensorValue build_coco_quantizer_ids( |
| 866 | engine::core::ModuleBuildContext & ctx, |
| 867 | const engine::core::TensorValue & encoder_output_btd, |
| 868 | const Vevo2CocoTokenizerWeights & weights, |
| 869 | const Vevo2CocoTokenizerConfig & config) { |
| 870 | auto hidden_bdt = engine::modules::TransposeModule({{0, 2, 1, 3}, 3}).build(ctx, encoder_output_btd); |
| 871 | auto projected_bdt = engine::modules::Conv1dModule({ |
| 872 | config.hidden_size, |
| 873 | config.codebook_dim, |
| 874 | 1, |
| 875 | 1, |
| 876 | 0, |
| 877 | 1, |
| 878 | weights.quantizer.in_project.bias.has_value(), |
| 879 | }).build(ctx, hidden_bdt, weights.quantizer.in_project); |
no test coverage detected