Skip to content

Commit 9dd8e40

Browse files
committed
rename print functions in baby-llama example
1 parent 47ad186 commit 9dd8e40

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

examples/baby-llama/baby-llama.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,15 +1017,15 @@ void sample_softmax(struct ggml_tensor * logits, struct ggml_tensor * probs, str
10171017
}
10181018
}
10191019

1020-
void print_probs1(struct ggml_tensor * probs, int i) {
1020+
void print_row(struct ggml_tensor * probs, int i) {
10211021
for (int k = 0; k < probs->ne[0]; ++k) {
10221022
float p = ggml_get_f32_1d(probs, i*probs->ne[0] + k);
10231023
printf(" %.2f", p);
10241024
}
10251025
printf("\n");
10261026
}
10271027

1028-
void print_probs(struct ggml_tensor * probs) {
1028+
void print_matrix(struct ggml_tensor * probs) {
10291029
assert(probs->n_dims == 2);
10301030
for (int i=0; i<probs->ne[1]; ++i) {
10311031
for (int k = 0; k < probs->ne[0]; ++k) {
@@ -1177,7 +1177,7 @@ int main(int argc, char ** argv) {
11771177
size_t compute_size = 1024ll*1024ll*1024ll;
11781178
uint8_t * compute_addr = new uint8_t[compute_size];
11791179

1180-
int n_examples = 256;
1180+
int n_examples = 25600;
11811181
int n_tokens = model.hparams.n_ctx;
11821182
int n_vocab = model.hparams.n_vocab;
11831183

@@ -1213,7 +1213,7 @@ int main(int argc, char ** argv) {
12131213
get_example_targets(64*ex+16, tokens_input2, targets2);
12141214
// get_example_targets(64*ex+32, tokens_input3, targets3);
12151215
// get_example_targets(64*ex+48, tokens_input4, targets4);
1216-
// print_probs(targets);
1216+
// print_matrix(targets);
12171217
// print_tokens(tokens_input, n_vocab);
12181218

12191219
struct ggml_tensor * logits1 = forward(&model, &kv_self, ctx0, &gf, tokens_input1, n_tokens, n_past);
@@ -1245,7 +1245,7 @@ int main(int argc, char ** argv) {
12451245
// sample_softmax(logits1, before_opt_probs, before_opt_best_samples);
12461246

12471247
// printf("probabilities before optimization:\n");
1248-
// print_probs(before_opt_probs);
1248+
// print_matrix(before_opt_probs);
12491249
// printf("best samples before optimization:\n");
12501250
// print_tokens(before_opt_best_samples, n_vocab);
12511251

@@ -1275,7 +1275,7 @@ int main(int argc, char ** argv) {
12751275
if (ex % 64 == 0) {
12761276
sample_softmax(logits1, after_opt_probs, after_opt_best_samples);
12771277
// printf("probabilities after optimization:\n");
1278-
// print_probs(after_opt_probs);
1278+
// print_matrix(after_opt_probs);
12791279
printf("best samples after optimization:\n");
12801280
print_tokens(after_opt_best_samples, n_vocab);
12811281
}
@@ -1326,7 +1326,7 @@ int main(int argc, char ** argv) {
13261326
// int sample_at = n_tokens-1;
13271327
int token = ggml_get_i32_1d(best_samples, sample_ctx-1);
13281328

1329-
// print_probs1(probs, sample_at);
1329+
// print_row(probs, sample_at);
13301330
print_token(token, n_vocab);
13311331

13321332
lshift_examples(tokens_input, targets, 1);

0 commit comments

Comments
 (0)