| 493 | } |
| 494 | |
| 495 | core::TensorValue build_vibevoice_diffusion_head( |
| 496 | core::ModuleBuildContext & ctx, |
| 497 | const core::TensorValue & noisy_images, |
| 498 | const core::TensorValue & timesteps, |
| 499 | const core::TensorValue & condition, |
| 500 | const VibeVoiceDiffusionHeadWeights & weights, |
| 501 | const VibeVoiceDiffusionHeadConfig & config, |
| 502 | core::ConstantTensorCache & constants) { |
| 503 | validate_config(config); |
| 504 | core::validate_shape(noisy_images, core::TensorShape::from_dims({noisy_images.shape.dims[0], config.latent_size}), "noisy_images"); |
| 505 | core::validate_shape(condition, core::TensorShape::from_dims({noisy_images.shape.dims[0], config.hidden_size}), "condition"); |
| 506 | core::validate_shape(timesteps, core::TensorShape::from_dims({noisy_images.shape.dims[0]}), "timesteps"); |
| 507 | if (static_cast<int64_t>(weights.layers.size()) != config.head_layers) { |
| 508 | throw std::runtime_error("VibeVoice diffusion head layer count mismatch"); |
| 509 | } |
| 510 | |
| 511 | auto x = modules::LinearModule( |
| 512 | binding::linear_config(config.latent_size, config.hidden_size, false)) |
| 513 | .build(ctx, noisy_images, weights.noisy_images_proj); |
| 514 | auto time_embedding = build_timestep_embedding(ctx, timesteps, weights, config); |
| 515 | auto projected_condition = modules::LinearModule( |
| 516 | binding::linear_config(config.hidden_size, config.hidden_size, false)) |
| 517 | .build(ctx, condition, weights.cond_proj); |
| 518 | auto c = add_tensors(ctx, projected_condition, time_embedding); |
| 519 | for (const auto & layer : weights.layers) { |
| 520 | x = build_head_layer(ctx, x, c, layer, config, weights.ones, constants); |
| 521 | } |
| 522 | return build_final_layer(ctx, x, c, weights, config); |
| 523 | } |
| 524 | |
| 525 | } // namespace engine::models::vibevoice |
no test coverage detected