@@ -637,7 +637,7 @@ void load_vocab(const char *filename, Config *config, struct llama_vocab *vocab)
637
637
}
638
638
}
639
639
640
- void stuff_karpathy_weights_into_gg (struct ggml_tensor * gg_weights, const float * karpathy_weights) {
640
+ void convert_weights_ak_to_gg (struct ggml_tensor * gg_weights, const float * karpathy_weights) {
641
641
int ct;
642
642
switch (gg_weights->n_dims ){
643
643
case 1 :
@@ -674,13 +674,13 @@ void stuff_karpathy_weights_into_gg(struct ggml_tensor * gg_weights, const float
674
674
}
675
675
676
676
void save_as_llama_model (struct llama_vocab * vocab, struct my_llama_model * model, TransformerWeights* w, const char * filename) {
677
- // stuff AK weights into GG weights one by one.
677
+ // convert AK weights into GG weights one by one.
678
678
// w->token_embedding_table -> model->tok_embeddings
679
679
// float* -> struct ggml_tensor
680
- stuff_karpathy_weights_into_gg (model->tok_embeddings , w->token_embedding_table );
681
- stuff_karpathy_weights_into_gg (model->output , w->wcls ? w->wcls : w->token_embedding_table );
680
+ convert_weights_ak_to_gg (model->tok_embeddings , w->token_embedding_table );
681
+ convert_weights_ak_to_gg (model->output , w->wcls ? w->wcls : w->token_embedding_table );
682
682
683
- stuff_karpathy_weights_into_gg (model->norm , w->rms_final_weight );
683
+ convert_weights_ak_to_gg (model->norm , w->rms_final_weight );
684
684
// print_row(model->norm, 0);
685
685
686
686
// for rms-att-weight
@@ -690,18 +690,18 @@ void save_as_llama_model(struct llama_vocab * vocab, struct my_llama_model * mod
690
690
for (uint32_t i = 0 ; i < model->hparams .n_layer ; ++i){
691
691
auto & layer = model->layers [i];
692
692
// 1d
693
- stuff_karpathy_weights_into_gg (layer.attention_norm , &w->rms_att_weight [i*row_length]);
694
- stuff_karpathy_weights_into_gg (layer.ffn_norm , &w->rms_ffn_weight [i*row_length]);
693
+ convert_weights_ak_to_gg (layer.attention_norm , &w->rms_att_weight [i*row_length]);
694
+ convert_weights_ak_to_gg (layer.ffn_norm , &w->rms_ffn_weight [i*row_length]);
695
695
696
696
// from 3d matrix layer x dim x dim to 2d matrix dim x dim
697
- stuff_karpathy_weights_into_gg (layer.wq , &w->wq [i*row_length*row_length]);
698
- stuff_karpathy_weights_into_gg (layer.wk , &w->wk [i*row_length*row_length]);
699
- stuff_karpathy_weights_into_gg (layer.wv , &w->wv [i*row_length*row_length]);
700
- stuff_karpathy_weights_into_gg (layer.wo , &w->wo [i*row_length*row_length]);
701
-
702
- stuff_karpathy_weights_into_gg (layer.w1 , &w->w1 [i*row_length*n_ff]);
703
- stuff_karpathy_weights_into_gg (layer.w2 , &w->w2 [i*n_ff*row_length]);
704
- stuff_karpathy_weights_into_gg (layer.w3 , &w->w3 [i*row_length*n_ff]);
697
+ convert_weights_ak_to_gg (layer.wq , &w->wq [i*row_length*row_length]);
698
+ convert_weights_ak_to_gg (layer.wk , &w->wk [i*row_length*row_length]);
699
+ convert_weights_ak_to_gg (layer.wv , &w->wv [i*row_length*row_length]);
700
+ convert_weights_ak_to_gg (layer.wo , &w->wo [i*row_length*row_length]);
701
+
702
+ convert_weights_ak_to_gg (layer.w1 , &w->w1 [i*row_length*n_ff]);
703
+ convert_weights_ak_to_gg (layer.w2 , &w->w2 [i*n_ff*row_length]);
704
+ convert_weights_ak_to_gg (layer.w3 , &w->w3 [i*row_length*n_ff]);
705
705
}
706
706
707
707
struct gguf_context * ctx = gguf_init_empty ();
0 commit comments