#pragma once
#include "weights.h"
#include "ggml.h"
#include <cstdint>
struct ggml_context;
struct ggml_cgraph;
struct ggml_tensor;
namespace transcribe::granite_nar {
struct DecoderDumps {
ggml_tensor * flat_embeds = nullptr; ggml_tensor * text_logits = nullptr; };
struct ForwardBuild {
ggml_tensor * audio_in = nullptr; ggml_tensor * text_ids_in = nullptr; ggml_tensor * positions_in = nullptr;
ggml_tensor * out = nullptr;
DecoderDumps dumps {};
ggml_cgraph * graph = nullptr;
int n_audio_tokens = 0;
int n_text = 0;
int T_total = 0;
};
ForwardBuild build_forward_graph(ggml_context * ctx,
const GraniteNarWeights & weights,
const GraniteNarHParams & hp,
int n_audio_tokens,
int n_text);
void add_insertion_slots(const std::vector<int32_t> & hyp_ids,
int32_t eos_id,
std::vector<int32_t> & out);
void argmax_collapse_drop_eos(const std::vector<float> & text_logits,
int vocab,
int n_text,
int32_t eos_id,
std::vector<int32_t> & out_ids);
}