#pragma once
#include "ggml-backend.h"
#include "ggml.h"
#include "transcribe-backend.h"
#include "transcribe-load-common.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;
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::granite_nar {
void apply_family_invariants(transcribe_model & model);
struct GraniteNarModel final : public transcribe_model {
Tokenizer tok;
GraniteNarHParams hparams;
GraniteNarWeights weights;
ggml_context * ctx_meta = nullptr;
transcribe::BackendPlan plan;
transcribe::load_common::WeightStorage weight_storage;
ggml_context * bn_fused_ctx = nullptr;
ggml_backend_buffer_t bn_fused_buffer = nullptr;
std::optional<transcribe::MelFrontend> mel;
GraniteNarModel() = default;
~GraniteNarModel() override;
const transcribe::Tokenizer * tokenizer() const override { return &tok; }
};
struct GraniteNarSession final : public transcribe_session {
std::vector<float> mel_buf;
std::vector<float> enc_cat_host; std::vector<float> proj_out_host; int32_t t_enc = 0;
int32_t n_audio_tokens = 0;
bool encoder_use_flash = false;
bool decoder_use_flash = true;
GraniteNarSession() = default;
~GraniteNarSession() override;
};
}