| 1121 | } |
| 1122 | |
| 1123 | HeartCodecConditioning run(const std::vector<int32_t> & codes) { |
| 1124 | allocate_workspace(); |
| 1125 | const auto & config = runtime_->assets().codec_config; |
| 1126 | const size_t expected_codes = static_cast<size_t>(batch_size_ * config.num_quantizers * code_frames_); |
| 1127 | if (codes.size() != expected_codes) { |
| 1128 | throw std::runtime_error("HeartCodec conditioning code payload size mismatch"); |
| 1129 | } |
| 1130 | ggml_backend_tensor_set(input_, codes.data(), 0, codes.size() * sizeof(int32_t)); |
| 1131 | core::set_backend_threads(runtime_->backend(), runtime_->threads()); |
| 1132 | const ggml_status status = core::compute_backend_graph(runtime_->backend(), graph_); |
| 1133 | ggml_backend_synchronize(runtime_->backend()); |
| 1134 | if (status != GGML_STATUS_SUCCESS) { |
| 1135 | throw std::runtime_error("HeartCodec conditioning graph compute failed"); |
| 1136 | } |
| 1137 | HeartCodecConditioning out; |
| 1138 | out.batch_size = batch_size_; |
| 1139 | out.frames = output_frames_; |
| 1140 | out.channels = config.dim; |
| 1141 | out.values.resize(static_cast<size_t>(out.batch_size * out.frames * out.channels)); |
| 1142 | ggml_backend_tensor_get(output_, out.values.data(), 0, out.values.size() * sizeof(float)); |
| 1143 | return out; |
| 1144 | } |
| 1145 | |
| 1146 | private: |
| 1147 | void allocate_workspace() { |
no test coverage detected