| 376 | } |
| 377 | |
| 378 | std::vector<float> run(const std::vector<float> & waveform) { |
| 379 | if (static_cast<int64_t>(waveform.size()) != input_samples_) { |
| 380 | throw std::runtime_error("FlashSR input size changed without rebuilding graph"); |
| 381 | } |
| 382 | ggml_backend_tensor_set(input_, waveform.data(), 0, waveform.size() * sizeof(float)); |
| 383 | core::set_backend_threads(weights_.backend.get(), weights_.threads); |
| 384 | const auto status = core::compute_backend_graph(weights_.backend.get(), graph_, plan_, "FlashSR"); |
| 385 | ggml_backend_synchronize(weights_.backend.get()); |
| 386 | if (status != GGML_STATUS_SUCCESS) { |
| 387 | throw std::runtime_error("FlashSR GGML graph compute failed"); |
| 388 | } |
| 389 | std::vector<float> output(ggml_nelements(output_)); |
| 390 | ggml_backend_tensor_get(output_, output.data(), 0, output.size() * sizeof(float)); |
| 391 | return output; |
| 392 | } |
| 393 | |
| 394 | private: |
| 395 | const FlashSrWeights & weights_; |
no test coverage detected