| 609 | execution_context.backend(), |
| 610 | std::max(1, execution_context.config().threads), |
| 611 | assets != nullptr ? assets->config.family : std::string("roformer")) { |
| 612 | if (assets == nullptr) { |
| 613 | throw std::runtime_error("RoFormer graph requires assets"); |
| 614 | } |
| 615 | const auto build_start = Clock::now(); |
| 616 | const auto & config = assets->config; |
| 617 | weights_ = load_mel_band_weights(*assets, execution_context.backend(), execution_context.backend_type(), weight_storage_type); |
| 618 | |
| 619 | init_context(256ull * 1024ull * 1024ull); |
| 620 | constants_ = std::make_unique<core::ConstantTensorCache>( |
| 621 | backend_, |
| 622 | compute_threads_, |
| 623 | config.family + ".constants", |
| 624 | 4ull * 1024ull * 1024ull); |
| 625 | auto build_ctx = make_build_context(execution_context, config.family.c_str()); |
| 626 | constants_->begin_graph(); |
| 627 | input_shape_ = core::TensorShape::from_dims({1, config.chunk_frames, config.total_band_input_dim}); |
| 628 | output_shape_ = core::TensorShape::from_dims({1, config.chunk_frames, config.total_band_input_dim}); |
| 629 | |
| 630 | auto input = core::make_tensor(build_ctx, GGML_TYPE_F32, input_shape_); |
| 631 | input_ = input.tensor; |
| 632 | |
| 633 | const auto time_positions_host = make_positions(config.chunk_frames); |
| 634 | const auto time_positions = constants_->make_tensor( |
| 635 | core::TensorShape::from_dims({config.chunk_frames}), |
| 636 | GGML_TYPE_I32, |
| 637 | time_positions_host.data(), |
| 638 | time_positions_host.size() * sizeof(int32_t)); |
| 639 | |
| 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, |
no test coverage detected