#pragma once
#include "causal_lm/causal_lm.h"
#include "ggml-backend.h"
#include "ggml.h"
#include "transcribe-backend.h"
#include "transcribe-mel.h"
#include "transcribe-model.h"
#include "transcribe-session.h"
#include "transcribe-tokenizer.h"
#include "weights.h"
#include <cstdint>
#include <optional>
#include <string>
#include <vector>
struct ggml_context;
struct ggml_tensor;
struct ggml_backend;
struct ggml_backend_buffer;
struct ggml_backend_sched;
typedef struct ggml_backend * ggml_backend_t;
typedef struct ggml_backend_buffer * ggml_backend_buffer_t;
typedef struct ggml_backend_sched * ggml_backend_sched_t;
namespace transcribe::moss {
void apply_family_invariants(transcribe_model & model);
void build_audio_span(const MossHParams & hp,
int audio_seq_len,
std::vector<int32_t> & out_span_ids,
std::vector<int32_t> & out_audio_offsets);
void build_prompt_tokens(const MossHParams & hp,
int audio_seq_len,
std::vector<int32_t> & out_ids,
std::vector<int32_t> & out_audio_positions);
struct MossModel final : public transcribe_model {
Tokenizer tok;
MossHParams hparams;
MossWeights weights;
ggml_context * ctx_meta = nullptr;
transcribe::BackendPlan plan;
ggml_backend_buffer_t backend_buffer = nullptr;
transcribe::causal_lm::PackedGateUpHandles packed_gate_up;
std::optional<transcribe::MelFrontend> mel;
std::string chat_template;
MossModel() = default;
~MossModel() override;
const transcribe::Tokenizer * tokenizer() const override { return &tok; }
};
struct MossSession final : public transcribe_session {
ggml_context * compute_ctx = nullptr;
ggml_backend_sched_t sched = nullptr;
transcribe::causal_lm::KvCache kv_cache;
transcribe::causal_lm::KvCache kv_cache_batch;
int kv_batch_cap = 0;
int kv_batch_n_ctx = 0;
std::vector<float> mel_buf;
std::vector<float> enc_host;
bool encoder_use_flash = false;
bool decoder_use_flash = true;
MossSession() = default;
~MossSession() override;
};
}