| 574 | selected = core::ensure_backend_addressable_layout(ctx, modules::TransposeModule({{0, 2, 1}, 3}).build(ctx, selected)); |
| 575 | return core::reshape_tensor( |
| 576 | ctx, |
| 577 | selected, |
| 578 | core::TensorShape::from_dims({codes_bqt.shape.dims[0], codes_bqt.shape.dims[2]})); |
| 579 | } |
| 580 | |
| 581 | core::TensorValue conditioning_from_codes( |
| 582 | core::ModuleBuildContext & ctx, |
| 583 | const core::TensorValue & codes_bqt, |
| 584 | const HeartCodecFlowWeights & weights, |
| 585 | const HeartCodecConfig & config) { |
| 586 | core::TensorValue summed; |
| 587 | for (int64_t quantizer = 0; quantizer < config.num_quantizers; ++quantizer) { |
| 588 | auto indices = reshape_codebook_indices(ctx, codes_bqt, quantizer); |
| 589 | auto looked_up = modules::CodebookLookupModule({config.codebook_size, config.codebook_dim}) |
| 590 | .build(ctx, indices, weights.vq_codebooks[static_cast<size_t>(quantizer)]); |
| 591 | summed = summed.valid() ? modules::AddModule{}.build(ctx, summed, looked_up) : looked_up; |
| 592 | } |
| 593 | auto projected = modules::LinearModule({config.codebook_dim, config.dim, true, GGML_PREC_F32}) |
| 594 | .build(ctx, summed, weights.vq_project_out); |
| 595 | projected = modules::LinearModule({config.dim, config.dim, true, GGML_PREC_F32}) |
| 596 | .build(ctx, projected, weights.cond_feature_emb); |
| 597 | return adjacent_repeat_frames_btc(ctx, projected, 2); |
no test coverage detected