MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / encode

Method encode

src/framework/modules/hubert_encoder.cpp:324–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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
346private:

Callers

nothing calls this directly

Calls 5

compute_backend_graphFunction · 0.85
read_tensor_f32Function · 0.85
write_tensor_f32Function · 0.50
sizeMethod · 0.45
backendMethod · 0.45

Tested by

no test coverage detected