#pragma once #include "engine/framework/assets/tensor_source.h" #include "engine/framework/core/backend.h" #include "engine/models/dots_tts/latent.h" #include "engine/models/dots_tts/types.h" #include #include #include namespace engine::models::dots_tts { struct DotsProjectedSequence { std::vector values; int64_t steps = 0; int64_t hidden_size = 0; }; struct DotsVelocityOutput { std::vector values; int64_t frames = 0; int64_t latent_dim = 0; }; struct DotsFlowRuntimeStats { int64_t velocity_calls = 0; double modulation_graph_ms = 0.0; double modulation_input_upload_ms = 0.0; double modulation_compute_ms = 0.0; double velocity_graph_ms = 0.0; double velocity_input_upload_ms = 0.0; double velocity_compute_ms = 0.0; double velocity_output_read_ms = 0.0; }; class DotsFlowDecodeState { public: DotsFlowDecodeState(); DotsFlowDecodeState(DotsFlowDecodeState &&) noexcept; DotsFlowDecodeState & operator=(DotsFlowDecodeState &&) noexcept; DotsFlowDecodeState(const DotsFlowDecodeState &) = delete; DotsFlowDecodeState & operator=(const DotsFlowDecodeState &) = delete; ~DotsFlowDecodeState(); private: struct Impl; std::unique_ptr impl_; friend class DotsFlowComponent; }; struct DotsFlowDecodeRequest { const std::vector * sequence = nullptr; const std::vector * cfg_sequence = nullptr; const std::vector * speaker_condition = nullptr; int64_t fm_seq_len = 0; int64_t num_inference_steps = 0; DotsOdeMethod ode_method = DotsOdeMethod::Euler; float guidance_scale = 1.0F; uint64_t seed = 0; uint64_t rng_offset_blocks = 0; int64_t cache_capacity = 0; bool use_cached_dit = false; DotsFlowRuntimeStats * runtime_stats = nullptr; DotsFlowDecodeState * decode_state = nullptr; }; class DotsFlowComponent { public: static DotsFlowComponent load_from_tensor_source( std::shared_ptr source, core::BackendConfig backend, DotsConfig config, assets::TensorStorageType weight_storage_type); DotsFlowComponent(); DotsFlowComponent(DotsFlowComponent &&) noexcept; DotsFlowComponent & operator=(DotsFlowComponent &&) noexcept; DotsFlowComponent(const DotsFlowComponent &) = delete; DotsFlowComponent & operator=(const DotsFlowComponent &) = delete; ~DotsFlowComponent(); bool is_loaded() const noexcept; DotsProjectedSequence project_llm_hidden(const std::vector & hidden, int64_t steps) const; DotsProjectedSequence project_latents(const std::vector & latents, int64_t frames) const; DotsProjectedSequence project_speaker(const std::vector & speaker) const; DotsVelocityOutput predict_velocity( const std::vector & sequence, int64_t steps, const std::vector & timesteps, const std::vector & durations, const std::vector & speaker_condition, int64_t batch_size, const std::vector & positions = {}, const std::vector & attention_mask = {}) const; DotsLatentMatrix decode_next_soar(const DotsFlowDecodeRequest & request) const; DotsLatentMatrix decode_next_meanflow(const DotsFlowDecodeRequest & request) const; void release_runtime_graphs(); private: struct Impl; std::unique_ptr impl_; }; } // namespace engine::models::dots_tts