Skip to content

Commit 0d58936

Browse files
committed
llama2c : rename function
1 parent 6c9c234 commit 0d58936

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ void load_vocab(const char *filename, Config *config, struct llama_vocab *vocab)
637637
}
638638
}
639639

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) {
641641
int ct;
642642
switch (gg_weights->n_dims){
643643
case 1:
@@ -674,13 +674,13 @@ void stuff_karpathy_weights_into_gg(struct ggml_tensor * gg_weights, const float
674674
}
675675

676676
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.
678678
// w->token_embedding_table -> model->tok_embeddings
679679
// 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);
682682

683-
stuff_karpathy_weights_into_gg(model->norm, w->rms_final_weight);
683+
convert_weights_ak_to_gg(model->norm, w->rms_final_weight);
684684
//print_row(model->norm, 0);
685685

686686
// for rms-att-weight
@@ -690,18 +690,18 @@ void save_as_llama_model(struct llama_vocab * vocab, struct my_llama_model * mod
690690
for (uint32_t i = 0; i < model->hparams.n_layer; ++i){
691691
auto & layer = model->layers[i];
692692
// 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]);
695695

696696
// 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]);
705705
}
706706

707707
struct gguf_context * ctx = gguf_init_empty();

0 commit comments

Comments
 (0)