#pragma once #include "engine/framework/assets/tensor_source.h" #include "engine/framework/core/backend.h" #include "engine/framework/core/backend_weight_store.h" #include "engine/framework/modules/transformers/causal_decoder.h" #include "engine/models/personaplex/assets.h" #include "ggml-backend.h" #include #include #include #include namespace engine::models::personaplex { constexpr size_t kPersonaPlexDelayedStreamCount = 17; struct PersonaPlexLMWeights { std::shared_ptr store; modules::CausalDecoderWeights main; core::TensorValue text_embedding; std::vector audio_embeddings; }; modules::CausalDecoderConfig personaplex_lm_decoder_config( const PersonaPlexConfig & config, core::BackendType backend_type); std::shared_ptr load_personaplex_lm_weights( const PersonaPlexAssets & assets, ggml_backend_t backend, core::BackendType backend_type, size_t context_bytes, assets::TensorStorageType storage_type); struct PersonaPlexMainStepOutput { std::vector hidden; std::vector text_logits; }; struct PersonaPlexDelayedStep { std::array tokens{}; std::array target{}; std::array provided{}; int64_t model_input_position = 0; int64_t target_position = 0; }; class PersonaPlexMainStepGraph { public: PersonaPlexMainStepGraph( std::shared_ptr weights, PersonaPlexConfig config, ggml_backend_t backend, core::BackendType backend_type, int threads, size_t graph_arena_bytes); ~PersonaPlexMainStepGraph(); PersonaPlexMainStepOutput run_embedding_step(const std::vector & embedding); PersonaPlexMainStepOutput run_token_step(const std::array & tokens); void reset(); int64_t valid_steps() const noexcept; private: struct Impl; std::unique_ptr impl_; }; } // namespace engine::models::personaplex