| 996 | } |
| 997 | |
| 998 | HeartCodecFlowEstimate run( |
| 999 | const std::vector<float> & hidden_states, |
| 1000 | const std::vector<float> & timesteps) { |
| 1001 | allocate_workspace(); |
| 1002 | const auto & config = runtime_->assets().codec_config; |
| 1003 | const size_t expected_hidden = static_cast<size_t>(batch_size_ * frames_ * config.in_channels); |
| 1004 | if (hidden_states.size() != expected_hidden) { |
| 1005 | throw std::runtime_error("HeartCodec flow estimator hidden-state payload size mismatch"); |
| 1006 | } |
| 1007 | if (static_cast<int64_t>(timesteps.size()) != batch_size_) { |
| 1008 | throw std::runtime_error("HeartCodec flow estimator timestep payload size mismatch"); |
| 1009 | } |
| 1010 | ggml_backend_tensor_set(input_, hidden_states.data(), 0, hidden_states.size() * sizeof(float)); |
| 1011 | ggml_backend_tensor_set(timesteps_, timesteps.data(), 0, timesteps.size() * sizeof(float)); |
| 1012 | core::set_backend_threads(runtime_->backend(), runtime_->threads()); |
| 1013 | const ggml_status status = core::compute_backend_graph(runtime_->backend(), graph_); |
| 1014 | ggml_backend_synchronize(runtime_->backend()); |
| 1015 | if (status != GGML_STATUS_SUCCESS) { |
| 1016 | throw std::runtime_error("HeartCodec flow estimator graph compute failed"); |
| 1017 | } |
| 1018 | HeartCodecFlowEstimate out; |
| 1019 | out.batch_size = batch_size_; |
| 1020 | out.frames = frames_; |
| 1021 | out.channels = config.out_channels; |
| 1022 | out.values.resize(static_cast<size_t>(out.batch_size * out.frames * out.channels)); |
| 1023 | ggml_backend_tensor_get(output_, out.values.data(), 0, out.values.size() * sizeof(float)); |
| 1024 | return out; |
| 1025 | } |
| 1026 | |
| 1027 | private: |
| 1028 | void allocate_workspace() { |
nothing calls this directly
no test coverage detected