| 322 | if (batch != 1) { |
| 323 | throw std::runtime_error("HuBERT encoder currently requires batch size 1"); |
| 324 | } |
| 325 | if (samples <= 0 || static_cast<int64_t>(input_values.size()) != batch * samples) { |
| 326 | throw std::runtime_error("HuBERT encoder input size mismatch"); |
| 327 | } |
| 328 | ensure_graph(batch, samples); |
| 329 | core::write_tensor_f32(input_, input_values); |
| 330 | if (engine::core::compute_backend_graph(weights_->execution_context->backend(), graph_) != GGML_STATUS_SUCCESS) { |
| 331 | throw std::runtime_error("ggml_backend_graph_compute failed for HuBERT encoder"); |
| 332 | } |
| 333 | HubertEncoderOutput out; |
| 334 | out.hidden_states = core::read_tensor_f32(output_.tensor); |
| 335 | out.batch = batch; |
| 336 | out.tokens = output_.shape.dims[1]; |
| 337 | out.hidden_size = output_.shape.dims[2]; |
| 338 | return out; |
| 339 | } |
| 340 | |
| 341 | void release_runtime_graph() { |
| 342 | std::lock_guard<std::mutex> lock(mutex_); |
| 343 | release_graph(); |
| 344 | } |
| 345 | |
| 346 | private: |
nothing calls this directly
no test coverage detected