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

Function flatten_prefill_cache_by_step

src/models/heartmula/mula.cpp:460–483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

458}
459
460std::vector<float> flatten_prefill_cache_by_step(
461 const std::vector<float> & values,
462 int64_t batch,
463 int64_t steps,
464 int64_t heads,
465 int64_t dim) {
466 const size_t expected = static_cast<size_t>(batch * steps * heads * dim);
467 if (values.size() != expected) {
468 throw std::runtime_error("HeartMuLa backbone prefill cache tensor size mismatch");
469 }
470 std::vector<float> out(expected);
471 for (int64_t step = 0; step < steps; ++step) {
472 for (int64_t b = 0; b < batch; ++b) {
473 for (int64_t head = 0; head < heads; ++head) {
474 const size_t src = static_cast<size_t>(((b * steps + step) * heads + head) * dim);
475 const size_t dst = static_cast<size_t>(((step * batch + b) * heads + head) * dim);
476 std::copy(values.begin() + static_cast<ptrdiff_t>(src),
477 values.begin() + static_cast<ptrdiff_t>(src + dim),
478 out.begin() + static_cast<ptrdiff_t>(dst));
479 }
480 }
481 }
482 return out;
483}
484
485core::TensorValue codebook_audio_logits(
486 core::ModuleBuildContext & ctx,

Callers 2

runMethod · 0.85
runMethod · 0.85

Calls 3

copyFunction · 0.85
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected