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

Method cached_step

src/models/vibevoice/decoder.cpp:1644–1687  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1642}
1643
1644VibeVoiceDecoderResult VibeVoiceDecoderWeightsRuntime::cached_step(
1645 const std::vector<float> & embedding,
1646 VibeVoiceDecoderCachedState & state,
1647 int64_t cache_capacity) const {
1648 const auto & config = assets_->config.decoder;
1649 if (static_cast<int64_t>(embedding.size()) != config.hidden_size) {
1650 throw std::runtime_error("VibeVoice decoder cached step embedding payload size mismatch");
1651 }
1652 if (cache_capacity <= 0) {
1653 throw std::runtime_error("VibeVoice decoder cached step requires positive cache capacity");
1654 }
1655 if (state.batch_owner_ != nullptr) {
1656 export_and_drop_cached_batch_graph(state.batch_owner_);
1657 }
1658 const int64_t current_end = state.graph_has_state_ && state.graph_ != nullptr
1659 ? state.graph_->current_end()
1660 : state.pending_state_.current_end;
1661 const int64_t required_capacity = cache_graph_capacity(
1662 std::max<int64_t>(cache_capacity, current_end + 1),
1663 config.max_position_embeddings);
1664 if (state.graph_ != nullptr && state.graph_has_state_ && !state.graph_->can_decode(*this, required_capacity)) {
1665 state.pending_state_ = state.graph_->export_state();
1666 state.graph_has_state_ = false;
1667 }
1668 if (state.graph_ == nullptr || !state.graph_->can_decode(*this, required_capacity)) {
1669 state.graph_.reset();
1670 const size_t graph_arena_bytes = required_capacity >= kScratchTailCachedAttentionMinSteps
1671 ? 1536ull * 1024ull * 1024ull
1672 : 1024ull * 1024ull * 1024ull;
1673 state.graph_ = std::make_unique<VibeVoiceDecoderCachedStepGraph>(
1674 *this,
1675 required_capacity,
1676 graph_arena_bytes);
1677 }
1678 if (!state.graph_has_state_) {
1679 if (state.pending_state_.layers.empty() && state.pending_state_.current_end == 0) {
1680 state.pending_state_ = empty_decoder_state(weights_->layers.size());
1681 }
1682 state.graph_->import_state(state.pending_state_);
1683 state.pending_state_ = {};
1684 state.graph_has_state_ = true;
1685 }
1686 return state.graph_->run_step(embedding);
1687}
1688
1689std::vector<VibeVoiceDecoderResult> VibeVoiceDecoderWeightsRuntime::cached_step_batch(
1690 const std::vector<std::vector<float>> & embeddings,

Callers 1

generate_vibevoiceFunction · 0.80

Calls 10

cache_graph_capacityFunction · 0.85
empty_decoder_stateFunction · 0.85
can_decodeMethod · 0.80
sizeMethod · 0.45
current_endMethod · 0.45
export_stateMethod · 0.45
resetMethod · 0.45
emptyMethod · 0.45
import_stateMethod · 0.45
run_stepMethod · 0.45

Tested by

no test coverage detected