| 181 | } |
| 182 | |
| 183 | core::TensorValue build_head_layer( |
| 184 | core::ModuleBuildContext & ctx, |
| 185 | const core::TensorValue & x, |
| 186 | const core::TensorValue & c, |
| 187 | const VibeVoiceDiffusionHeadLayerWeights & weights, |
| 188 | const VibeVoiceDiffusionHeadConfig & config, |
| 189 | const core::TensorValue & ones, |
| 190 | core::ConstantTensorCache & constants) { |
| 191 | auto modulation = modules::LinearModule( |
| 192 | binding::linear_config(config.hidden_size, 3 * config.hidden_size, false)) |
| 193 | .build(ctx, modules::SiluModule{}.build(ctx, c), weights.ada_ln); |
| 194 | auto shift = modules::SliceModule({static_cast<int>(modulation.shape.rank - 1), 0, config.hidden_size}).build(ctx, modulation); |
| 195 | auto scale = modules::SliceModule({static_cast<int>(modulation.shape.rank - 1), config.hidden_size, config.hidden_size}).build(ctx, modulation); |
| 196 | auto gate = modules::SliceModule({static_cast<int>(modulation.shape.rank - 1), 2 * config.hidden_size, config.hidden_size}).build(ctx, modulation); |
| 197 | auto normed = modules::RMSNormModule({config.hidden_size, config.rms_norm_eps, true, false}) |
| 198 | .build(ctx, x, binding::norm_data(constants, weights.norm)); |
| 199 | auto ffn_input = modulate(ctx, normed, shift, scale, ones); |
| 200 | return add_tensors(ctx, x, mul_tensors(ctx, gate, build_swiglu(ctx, ffn_input, weights, config))); |
| 201 | } |
| 202 | |
| 203 | core::TensorValue build_final_layer( |
| 204 | core::ModuleBuildContext & ctx, |
no test coverage detected