| 896 | return engine::core::reshape_tensor( |
| 897 | ctx, |
| 898 | ids, |
| 899 | engine::core::TensorShape::from_dims({1, projected_btd.shape.dims[1]})); |
| 900 | } |
| 901 | |
| 902 | } // namespace |
| 903 | |
| 904 | struct Vevo2CocoTokenizerGraph { |
| 905 | Vevo2CocoTokenizerGraph( |
| 906 | ggml_backend_t backend, |
| 907 | engine::core::BackendType backend_type, |
| 908 | size_t graph_context_bytes, |
| 909 | const Vevo2CocoTokenizerConfig & config, |
| 910 | const Vevo2CocoTokenizerWeights & weights, |
| 911 | int64_t feature_frames) |
| 912 | : backend(backend), |
| 913 | uses_whisper(config.coco_type == "content_style"), |
| 914 | feature_frames(feature_frames), |
| 915 | output_frames(coco_output_frames(feature_frames, config.downsample_rate)) { |
| 916 | if (backend == nullptr) { |
| 917 | throw std::runtime_error("Vevo2 Coco tokenizer graph backend is not initialized"); |
| 918 | } |
| 919 | if (feature_frames <= 0) { |
| 920 | throw std::runtime_error("Vevo2 Coco tokenizer graph requires positive feature frames"); |
| 921 | } |
| 922 | if (uses_whisper && !weights.whisper_input.has_value()) { |
| 923 | throw std::runtime_error("Vevo2 content-style tokenizer graph requires Whisper input weights"); |
| 924 | } |
| 925 | if (!weights.chromagram_input.has_value()) { |
| 926 | throw std::runtime_error("Vevo2 Coco tokenizer graph requires chromagram input weights"); |
| 927 | } |
| 928 | |
| 929 | ggml_init_params params{graph_context_bytes, nullptr, true}; |
| 930 | ctx.reset(ggml_init(params)); |
| 931 | if (ctx == nullptr) { |
| 932 | throw std::runtime_error("failed to initialize Vevo2 Coco tokenizer graph context"); |
| 933 | } |
| 934 | |
| 935 | engine::core::ModuleBuildContext build_ctx{ctx.get(), "vevo2.coco_tokenizer", backend_type}; |
| 936 | chromagram_input = engine::core::make_tensor( |
no test coverage detected