#pragma once
#include "causal_lm/causal_lm.h"
#include "ggml.h"
#include <vector>
struct ggml_context;
struct ggml_tensor;
struct ggml_cgraph;
namespace transcribe::voxtral_realtime {
struct HParams;
struct Weights;
struct EncoderDumps {
ggml_tensor * embedder_out = nullptr; ggml_tensor * enc_out = nullptr; ggml_tensor * proj_out = nullptr; std::vector<ggml_tensor *> block_outs; };
struct EncoderBuild {
ggml_tensor * mel_in = nullptr; ggml_tensor * positions_in = nullptr; ggml_tensor * mask_in = nullptr; ggml_tensor * out = nullptr; EncoderDumps dumps{};
ggml_cgraph * graph = nullptr;
int T_enc = 0;
int n_audio = 0;
};
EncoderBuild build_encoder_graph(ggml_context * ctx,
const Weights & weights,
const HParams & hp,
int n_mel_frames,
bool use_flash);
struct EncoderBuildBatched {
ggml_tensor * mel_in = nullptr; ggml_tensor * positions_in = nullptr; ggml_tensor * mask_in = nullptr; ggml_tensor * out = nullptr; ggml_cgraph * graph = nullptr;
int T_enc = 0;
int n_audio = 0;
int n_batch = 0;
};
EncoderBuildBatched build_encoder_graph_batched(ggml_context * ctx,
const Weights & weights,
const HParams & hp,
int n_mel_frames,
int n_batch,
bool use_flash);
struct EmbedderBuild {
ggml_tensor * mel_in = nullptr; ggml_tensor * out = nullptr; ggml_cgraph * graph = nullptr;
int T_enc = 0;
};
EmbedderBuild build_embedder_graph(ggml_context * ctx, const Weights & weights, const HParams & hp, int n_mel_frames);
struct EmbedderChunkBuild {
ggml_tensor * mel_in = nullptr; ggml_tensor * cache1_in = nullptr; ggml_tensor * cache2_in = nullptr; ggml_tensor * out = nullptr; ggml_tensor * cache2_out = nullptr; ggml_cgraph * graph = nullptr;
int M_emb = 0;
};
EmbedderChunkBuild build_embedder_chunk_graph(ggml_context * ctx,
const Weights & weights,
const HParams & hp,
int n_new_mel);
struct EncoderChunkBuild {
ggml_tensor * embed_in = nullptr; ggml_tensor * positions_in = nullptr; ggml_tensor * mask_in = nullptr; ggml_tensor * out = nullptr; ggml_tensor * enc_out = nullptr; ggml_cgraph * graph = nullptr;
int n_new = 0;
int read_len = 0;
int n_audio_new = 0;
};
EncoderChunkBuild build_encoder_chunk_graph(ggml_context * ctx,
const Weights & weights,
const HParams & hp,
transcribe::causal_lm::KvCache & enc_kv,
int n_new,
int write_slot,
int read_start,
int read_len,
bool use_flash);
}