| 8760 | l->hc_attn_fn = dspark_bind_tensor(dw, m, stage, "hc_attn_fn.weight", true); |
| 8761 | l->hc_attn_scale = dspark_bind_tensor(dw, m, stage, "hc_attn_scale.weight", true); |
| 8762 | l->hc_attn_base = dspark_bind_tensor(dw, m, stage, "hc_attn_base.weight", true); |
| 8763 | l->attn_norm = dspark_bind_tensor(dw, m, stage, "attn_norm.weight", true); |
| 8764 | l->attn_q_a = dspark_bind_tensor(dw, m, stage, "attn_q_a.weight", true); |
| 8765 | l->attn_q_a_norm = dspark_bind_tensor(dw, m, stage, "attn_q_a_norm.weight", true); |
| 8766 | l->attn_q_b = dspark_bind_tensor(dw, m, stage, "attn_q_b.weight", true); |
| 8767 | l->attn_kv = dspark_bind_tensor(dw, m, stage, "attn_kv.weight", true); |
| 8768 | l->attn_kv_a_norm = dspark_bind_tensor(dw, m, stage, "attn_kv_a_norm.weight", true); |
| 8769 | l->attn_sinks = dspark_bind_tensor(dw, m, stage, "attn_sinks.weight", true); |
| 8770 | l->attn_output_a = dspark_bind_tensor(dw, m, stage, "attn_output_a.weight", true); |
| 8771 | l->attn_output_b = dspark_bind_tensor(dw, m, stage, "attn_output_b.weight", true); |
| 8772 | l->hc_ffn_fn = dspark_bind_tensor(dw, m, stage, "hc_ffn_fn.weight", true); |
| 8773 | l->hc_ffn_scale = dspark_bind_tensor(dw, m, stage, "hc_ffn_scale.weight", true); |
| 8774 | l->hc_ffn_base = dspark_bind_tensor(dw, m, stage, "hc_ffn_base.weight", true); |
| 8775 | l->ffn_norm = dspark_bind_tensor(dw, m, stage, "ffn_norm.weight", true); |
| 8776 | l->ffn_gate_inp = dspark_bind_tensor(dw, m, stage, "ffn_gate_inp.weight", true); |
| 8777 | l->ffn_exp_probs_b = dspark_bind_tensor(dw, m, stage, "exp_probs_b.bias", true); |
| 8778 | l->ffn_gate_exps = dspark_bind_tensor(dw, m, stage, "ffn_gate_exps.weight", true); |
| 8779 | l->ffn_up_exps = dspark_bind_tensor(dw, m, stage, "ffn_up_exps.weight", true); |
| 8780 | l->ffn_down_exps = dspark_bind_tensor(dw, m, stage, "ffn_down_exps.weight", true); |
| 8781 | l->ffn_gate_shexp = dspark_bind_tensor(dw, m, stage, "ffn_gate_shexp.weight", true); |
| 8782 | l->ffn_up_shexp = dspark_bind_tensor(dw, m, stage, "ffn_up_shexp.weight", true); |
| 8783 | l->ffn_down_shexp = dspark_bind_tensor(dw, m, stage, "ffn_down_shexp.weight", true); |
| 8784 | } |
| 8785 | |
| 8786 | static void dspark_weights_bind_optional( |
| 8787 | ds4_dspark_weights *dw, |
| 8788 | const ds4_model *m, |
| 8789 | const ds4_dspark_summary *summary) { |
| 8790 | memset(dw, 0, sizeof(*dw)); |
| 8791 | if (!m || !summary) return; |
| 8792 | |
| 8793 | dw->n_stages = summary->stages < DS4_DSPARK_MAX_STAGES ? |
| 8794 | summary->stages : DS4_DSPARK_MAX_STAGES; |
| 8795 | dw->block_size = summary->block_size; |
| 8796 | dw->markov_rank = summary->markov_rank; |
| 8797 | dw->noise_token_id = summary->noise_token_id; |
| 8798 | dw->target_layer_count = summary->target_layer_count; |
| 8799 | dw->has_block_size = summary->has_block_size; |
| 8800 | dw->has_markov_rank = summary->has_markov_rank; |
| 8801 | dw->has_noise_token_id = summary->has_noise_token_id; |
| 8802 | dw->has_target_layers = summary->has_target_layers; |
| 8803 | memcpy(dw->target_layers, |
| 8804 | summary->target_layers, |
| 8805 | (size_t)dw->target_layer_count * sizeof(dw->target_layers[0])); |
| 8806 | if (summary->stages > DS4_DSPARK_MAX_STAGES) dw->missing_tensors++; |
| 8807 | |
| 8808 | for (uint32_t stage = 0; stage < dw->n_stages; stage++) { |
| 8809 | ds4_dspark_stage_weights *sw = &dw->stage[stage]; |
| 8810 | dspark_bind_block(dw, &sw->block, m, stage); |
| 8811 | if (stage == 0) { |
| 8812 | sw->main_proj = dspark_bind_tensor(dw, m, stage, "main_proj.weight", true); |
| 8813 | sw->main_norm = dspark_bind_tensor(dw, m, stage, "main_norm.weight", true); |
| 8814 | } |
| 8815 | } |
| 8816 | |
| 8817 | if (dw->n_stages != 0) { |
| 8818 | const uint32_t final_stage = dw->n_stages - 1u; |
| 8819 | ds4_dspark_stage_weights *sw = &dw->stage[final_stage]; |
no test coverage detected