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

Method decoder_cached_step

src/models/heartmula/mula.cpp:2012–2060  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2010}
2011
2012HeartMuLaDecoderResult HeartMuLaWeightsRuntime::decoder_cached_step(
2013 const std::vector<float> & embedding,
2014 int64_t batch_size,
2015 int64_t codebook_index,
2016 HeartMuLaDecoderCachedState & state,
2017 int64_t cache_capacity) const {
2018 const auto & full_config = assets_->mula_config;
2019 if (batch_size <= 0) {
2020 throw std::runtime_error("HeartMuLa decoder cached step requires positive batch size");
2021 }
2022 if (cache_capacity <= 0) {
2023 throw std::runtime_error("HeartMuLa decoder cached step requires positive cache capacity");
2024 }
2025 if (cache_capacity > full_config.decoder.max_seq_len) {
2026 throw std::runtime_error("HeartMuLa decoder cached step exceeds model context length");
2027 }
2028 if (codebook_index < 0 || codebook_index >= full_config.audio_num_codebooks - 1) {
2029 throw std::runtime_error("HeartMuLa decoder cached step codebook index is out of range");
2030 }
2031 if (static_cast<int64_t>(embedding.size()) != batch_size * full_config.backbone.embed_dim) {
2032 throw std::runtime_error("HeartMuLa decoder cached step embedding payload size mismatch");
2033 }
2034 const int64_t current_end = state.graph_has_state_ && decoder_cached_step_graph_ != nullptr
2035 ? decoder_cached_step_graph_->current_end()
2036 : state.pending_state_.current_end;
2037 const int64_t required_capacity = std::max<int64_t>(cache_capacity, current_end + 1);
2038 if (required_capacity > full_config.decoder.max_seq_len) {
2039 throw std::runtime_error("HeartMuLa decoder cached step capacity exceeds model context length");
2040 }
2041 if (decoder_cached_step_graph_ != nullptr && state.graph_has_state_ &&
2042 !decoder_cached_step_graph_->can_run(*this, batch_size, required_capacity)) {
2043 state.pending_state_ = decoder_cached_step_graph_->export_state();
2044 state.graph_has_state_ = false;
2045 }
2046 if (decoder_cached_step_graph_ == nullptr ||
2047 !decoder_cached_step_graph_->can_run(*this, batch_size, required_capacity)) {
2048 decoder_cached_step_graph_.reset();
2049 decoder_cached_step_graph_ = std::make_unique<HeartMuLaDecoderCachedStepGraph>(
2050 *this,
2051 batch_size,
2052 required_capacity);
2053 }
2054 if (!state.graph_has_state_) {
2055 decoder_cached_step_graph_->import_state(state.pending_state_);
2056 state.pending_state_ = {};
2057 state.graph_has_state_ = true;
2058 }
2059 return decoder_cached_step_graph_->run_step(embedding, codebook_index);
2060}
2061
2062HeartMuLaMergedEmbeddings HeartMuLaWeightsRuntime::merge_frame_embeddings(
2063 const HeartMuLaFrameEmbeddingInputs & inputs) const {

Callers 1

Calls 7

sizeMethod · 0.45
current_endMethod · 0.45
can_runMethod · 0.45
export_stateMethod · 0.45
resetMethod · 0.45
import_stateMethod · 0.45
run_stepMethod · 0.45

Tested by

no test coverage detected