#pragma once
#include "transcribe.h"
#include <cstdint>
#include <string>
#include <vector>
struct gguf_context;
struct ggml_context;
struct ggml_tensor;
namespace transcribe::canary_qwen {
struct CanaryQwenHParams {
int32_t enc_n_layers = 0; int32_t enc_d_model = 0; int32_t enc_n_heads = 0; int32_t enc_d_ff = 0; int32_t enc_conv_kernel = 0; int32_t enc_subsampling_factor = 0; int32_t enc_subsampling_chans = 0; int32_t enc_pos_emb_max_len = 0;
int32_t perception_output_dim = 0;
int32_t audio_locator_id = -1;
int32_t dec_n_layers = 0; int32_t dec_hidden = 0; int32_t dec_intermediate = 0; int32_t dec_n_heads = 0; int32_t dec_n_kv_heads = 0; int32_t dec_head_dim = 0; int32_t dec_max_position = 0; int32_t dec_vocab_size = 0; float dec_rms_norm_eps = 0.0f; float dec_rope_theta = 0.0f; bool dec_tie_word_embeddings = true;
int32_t vocab_size = 0; int32_t bos_token_id = -1;
int32_t eos_token_id = -1;
int32_t fe_sample_rate = 0; int32_t fe_num_mels = 0; int32_t fe_n_fft = 0; int32_t fe_win_length = 0; int32_t fe_hop_length = 0; float fe_pre_emphasis = 0.0f; float fe_f_min = 0.0f; float fe_f_max = 0.0f; std::string fe_pad_mode; std::string fe_normalize; };
struct PreEncodeSlots {
ggml_tensor * conv0_w = nullptr;
ggml_tensor * conv0_b = nullptr;
ggml_tensor * conv2_w = nullptr;
ggml_tensor * conv2_b = nullptr;
ggml_tensor * conv3_w = nullptr;
ggml_tensor * conv3_b = nullptr;
ggml_tensor * conv5_w = nullptr;
ggml_tensor * conv5_b = nullptr;
ggml_tensor * conv6_w = nullptr;
ggml_tensor * conv6_b = nullptr;
ggml_tensor * out_w = nullptr;
ggml_tensor * out_b = nullptr;
};
struct EncBlockSlots {
ggml_tensor * norm_ff1_w = nullptr;
ggml_tensor * norm_ff1_b = nullptr;
ggml_tensor * ff1_lin1_w = nullptr;
ggml_tensor * ff1_lin1_b = nullptr;
ggml_tensor * ff1_lin2_w = nullptr;
ggml_tensor * ff1_lin2_b = nullptr;
ggml_tensor * norm_attn_w = nullptr;
ggml_tensor * norm_attn_b = nullptr;
ggml_tensor * attn_q_w = nullptr;
ggml_tensor * attn_q_b = nullptr;
ggml_tensor * attn_k_w = nullptr;
ggml_tensor * attn_k_b = nullptr;
ggml_tensor * attn_v_w = nullptr;
ggml_tensor * attn_v_b = nullptr;
ggml_tensor * attn_out_w = nullptr;
ggml_tensor * attn_out_b = nullptr;
ggml_tensor * attn_pos_w = nullptr; ggml_tensor * attn_pos_u = nullptr; ggml_tensor * attn_pos_v = nullptr;
ggml_tensor * norm_conv_w = nullptr;
ggml_tensor * norm_conv_b = nullptr;
ggml_tensor * conv_pw1_w = nullptr;
ggml_tensor * conv_pw1_b = nullptr;
ggml_tensor * conv_dw_w = nullptr;
ggml_tensor * conv_dw_b = nullptr;
ggml_tensor * conv_pw2_w = nullptr;
ggml_tensor * conv_pw2_b = nullptr;
ggml_tensor * conv_bn_w = nullptr;
ggml_tensor * conv_bn_b = nullptr;
ggml_tensor * conv_bn_rm = nullptr;
ggml_tensor * conv_bn_rv = nullptr;
ggml_tensor * conv_bn_fused_scale = nullptr;
ggml_tensor * conv_bn_fused_bias = nullptr;
ggml_tensor * norm_ff2_w = nullptr;
ggml_tensor * norm_ff2_b = nullptr;
ggml_tensor * ff2_lin1_w = nullptr;
ggml_tensor * ff2_lin1_b = nullptr;
ggml_tensor * ff2_lin2_w = nullptr;
ggml_tensor * ff2_lin2_b = nullptr;
ggml_tensor * norm_out_w = nullptr;
ggml_tensor * norm_out_b = nullptr;
};
struct PerceptionProjSlots {
ggml_tensor * weight = nullptr; ggml_tensor * bias = nullptr; };
struct DecEmbedSlots {
ggml_tensor * token_w = nullptr; };
struct DecBlockSlots {
ggml_tensor * norm_attn_w = nullptr;
ggml_tensor * norm_ffn_w = nullptr;
ggml_tensor * attn_q_w = nullptr;
ggml_tensor * attn_k_w = nullptr;
ggml_tensor * attn_v_w = nullptr;
ggml_tensor * attn_o_w = nullptr;
ggml_tensor * attn_q_norm = nullptr; ggml_tensor * attn_k_norm = nullptr;
ggml_tensor * ffn_gate_w = nullptr;
ggml_tensor * ffn_up_w = nullptr;
ggml_tensor * ffn_gate_up_w = nullptr; ggml_tensor * ffn_down_w = nullptr;
};
struct DecFinalSlots {
ggml_tensor * norm_w = nullptr; };
struct CanaryQwenWeights {
PreEncodeSlots pre_encode;
std::vector<EncBlockSlots> blocks; PerceptionProjSlots perception_proj;
DecEmbedSlots dec_embed;
std::vector<DecBlockSlots> dec_blocks; DecFinalSlots dec_final;
};
transcribe_status read_canary_qwen_hparams(gguf_context * gguf_ctx, CanaryQwenHParams & out);
transcribe_status build_canary_qwen_weights(ggml_context * ctx, const CanaryQwenHParams & hp, CanaryQwenWeights & out);
}