| 640 | const auto freq_positions_host = make_positions(config.num_bands); |
| 641 | const auto freq_positions = constants_->make_tensor( |
| 642 | core::TensorShape::from_dims({config.num_bands}), |
| 643 | GGML_TYPE_I32, |
| 644 | freq_positions_host.data(), |
| 645 | freq_positions_host.size() * sizeof(int32_t)); |
| 646 | |
| 647 | core::TensorValue x = build_band_split(build_ctx, input, weights_, config); |
| 648 | for (const auto & layer : weights_.layers) { |
| 649 | x = modules::TransposeModule({{0, 2, 1, 3}, x.shape.rank}).build(build_ctx, x); |
| 650 | x = core::reshape_tensor( |
| 651 | build_ctx, |
| 652 | ensure_contiguous(build_ctx, x), |
| 653 | core::TensorShape::from_dims({config.num_bands, config.chunk_frames, config.dim})); |
| 654 | x = build_transformer_branch(build_ctx, x, time_positions, layer.time_branch, config); |
| 655 | x = core::reshape_tensor( |
| 656 | build_ctx, |
| 657 | ensure_contiguous(build_ctx, x), |
| 658 | core::TensorShape::from_dims({1, config.num_bands, config.chunk_frames, config.dim})); |
| 659 | x = modules::TransposeModule({{0, 2, 1, 3}, x.shape.rank}).build(build_ctx, x); |
| 660 | x = ensure_contiguous(build_ctx, x); |
| 661 | |
| 662 | x = core::reshape_tensor( |
| 663 | build_ctx, |
| 664 | x, |
| 665 | core::TensorShape::from_dims({config.chunk_frames, config.num_bands, config.dim})); |
| 666 | x = build_transformer_branch(build_ctx, x, freq_positions, layer.freq_branch, config); |
| 667 | x = core::reshape_tensor( |
| 668 | build_ctx, |
| 669 | ensure_contiguous(build_ctx, x), |
| 670 | core::TensorShape::from_dims({1, config.chunk_frames, config.num_bands, config.dim})); |
| 671 | x = ensure_contiguous(build_ctx, x); |
| 672 | } |
| 673 | |
| 674 | if (config.has_final_norm) { |
| 675 | x = build_reference_rms_norm( |
| 676 | build_ctx, x, config.dim, weights_.final_norm); |
| 677 | } |
| 678 | auto output = build_mask_output(build_ctx, x, weights_, config); |
| 679 | output = ensure_contiguous(build_ctx, output); |
| 680 | output_ = output.tensor; |
| 681 | ggml_set_output(output_); |
| 682 | constants_->finish_graph(); |
| 683 | constants_->ensure_uploaded(); |
| 684 | finalize_graph(131072); |
| 685 | engine::debug::timing_log_scalar( |
| 686 | config.family + ".graph.build_ms", |
| 687 | engine::debug::elapsed_ms(build_start)); |
| 688 | engine::debug::timing_log_scalar( |
| 689 | config.family + ".graph.rebuilt", |
| 690 | true); |
| 691 | } |
| 692 | |
| 693 | private: |
| 694 | MelBandWeights weights_; |
| 695 | std::unique_ptr<core::ConstantTensorCache> constants_; |
| 696 | }; |
| 697 | |
| 698 | std::vector<float> build_band_features( |
| 699 | const engine::audio::AudioTensor & stft, |
no test coverage detected