@@ -305,9 +305,9 @@ struct ggml_tensor * get_tensor_ex( struct ggml_context * ctx, std::string name)
305
305
306
306
struct ggml_tensor * cur = ggml_get_tensor (ctx, name.c_str ());
307
307
if ( cur == NULL ) {
308
- fprintf (stdout, " %s: tensor '%s' not found!\n " , __func__, name.c_str ());
308
+ printf ( " %s: tensor '%s' not found!\n " , __func__, name.c_str ());
309
309
} else {
310
- // fprintf(stdout, "%s: n_dims = %d, name = '%s'\n", __func__, cur->n_dims, cur->name);
310
+ // printf( "%s: n_dims = %d, name = '%s'\n", __func__, cur->n_dims, cur->name);
311
311
}
312
312
313
313
return cur;
@@ -333,21 +333,21 @@ bool falcon_model_load(const std::string & fname, falcon_model & model, gpt2bpe_
333
333
return false ;
334
334
}
335
335
336
- fprintf (stdout, " %s: gguf version = %d\n " , __func__, gguf_get_version (ggufctx));
337
- fprintf (stdout, " %s: gguf alignment = %zu\n " , __func__, gguf_get_alignment (ggufctx));
338
- fprintf (stdout, " %s: gguf data offset = %zu\n " , __func__, gguf_get_data_offset (ggufctx));
336
+ printf ( " %s: gguf version = %d\n " , __func__, gguf_get_version (ggufctx));
337
+ printf ( " %s: gguf alignment = %zu\n " , __func__, gguf_get_alignment (ggufctx));
338
+ printf ( " %s: gguf data offset = %zu\n " , __func__, gguf_get_data_offset (ggufctx));
339
339
340
340
// print all kv
341
341
#if 0
342
342
{
343
343
const int n_kv = gguf_get_n_kv(ggufctx);
344
344
345
- fprintf(stdout, "%s: n_kv: %d\n", __func__, n_kv);
345
+ printf( "%s: n_kv: %d\n", __func__, n_kv);
346
346
347
347
for (int i = 0; i < n_kv; ++i) {
348
348
const char * key = gguf_get_key(ggufctx, i);
349
349
350
- fprintf(stdout, "%s: kv[%d]: key = %s\n", __func__, i, key);
350
+ printf( "%s: kv[%d]: key = %s\n", __func__, i, key);
351
351
}
352
352
}
353
353
#endif
@@ -357,21 +357,21 @@ bool falcon_model_load(const std::string & fname, falcon_model & model, gpt2bpe_
357
357
int keyidx;
358
358
359
359
keyidx = gguf_find_key (ggufctx, " general.name" );
360
- if (keyidx != -1 ) { fprintf (stdout, " %s: model name = %s\n " , __func__, gguf_get_val_str (ggufctx, keyidx)); }
360
+ if (keyidx != -1 ) { printf ( " %s: model name = %s\n " , __func__, gguf_get_val_str (ggufctx, keyidx)); }
361
361
keyidx = gguf_find_key (ggufctx, " general.description" );
362
- if (keyidx != -1 ) { fprintf (stdout, " %s: model description = %s\n " , __func__, gguf_get_val_str (ggufctx, keyidx)); }
362
+ if (keyidx != -1 ) { printf ( " %s: model description = %s\n " , __func__, gguf_get_val_str (ggufctx, keyidx)); }
363
363
keyidx = gguf_find_key (ggufctx, " general.author" );
364
- if (keyidx != -1 ) { fprintf (stdout, " %s: model author = %s\n " , __func__, gguf_get_val_str (ggufctx, keyidx)); }
364
+ if (keyidx != -1 ) { printf ( " %s: model author = %s\n " , __func__, gguf_get_val_str (ggufctx, keyidx)); }
365
365
keyidx = gguf_find_key (ggufctx, " general.license" );
366
- if (keyidx != -1 ) { fprintf (stdout, " %s: model license = %s\n " , __func__, gguf_get_val_str (ggufctx, keyidx)); }
366
+ if (keyidx != -1 ) { printf ( " %s: model license = %s\n " , __func__, gguf_get_val_str (ggufctx, keyidx)); }
367
367
keyidx = gguf_find_key (ggufctx, " general.architecture" );
368
- if (keyidx != -1 ) { fprintf (stdout, " %s: model architecture = %s\n " , __func__, gguf_get_val_str (ggufctx, keyidx)); }
368
+ if (keyidx != -1 ) { printf ( " %s: model architecture = %s\n " , __func__, gguf_get_val_str (ggufctx, keyidx)); }
369
369
keyidx = gguf_find_key (ggufctx, " general.file_type" );
370
- if (keyidx != -1 ) { fprintf (stdout, " %s: model file type = %s\n " , __func__, gguf_get_val_str (ggufctx, keyidx)); }
370
+ if (keyidx != -1 ) { printf ( " %s: model file type = %s\n " , __func__, gguf_get_val_str (ggufctx, keyidx)); }
371
371
keyidx = gguf_find_key (ggufctx, " gptneox.tensor_data_layout" );
372
- if (keyidx != -1 ) { fprintf (stdout, " %s: model data layout = %s\n " , __func__, gguf_get_val_str (ggufctx, keyidx)); }
372
+ if (keyidx != -1 ) { printf ( " %s: model data layout = %s\n " , __func__, gguf_get_val_str (ggufctx, keyidx)); }
373
373
keyidx = gguf_find_key (ggufctx, " general.source.hugginface.repository" );
374
- if (keyidx != -1 ) { fprintf (stdout, " %s: model source HF repo = %s\n " , __func__, gguf_get_val_str (ggufctx, keyidx)); }
374
+ if (keyidx != -1 ) { printf ( " %s: model source HF repo = %s\n " , __func__, gguf_get_val_str (ggufctx, keyidx)); }
375
375
}
376
376
377
377
// check required metadata
@@ -382,23 +382,23 @@ bool falcon_model_load(const std::string & fname, falcon_model & model, gpt2bpe_
382
382
keyidx = gguf_find_key (ggufctx, " general.architecture" );
383
383
if (keyidx != -1 ) {
384
384
if ( strcmp (gguf_get_val_str (ggufctx, keyidx), " falcon" ) != 0 ) {
385
- fprintf (stdout, " %s: model architecture not supported!\n " , __func__);
385
+ printf ( " %s: model architecture not supported!\n " , __func__);
386
386
return false ;
387
387
}
388
388
} else {
389
- fprintf (stdout, " %s: gguf model architecture not found!\n " , __func__);
389
+ printf ( " %s: gguf model architecture not found!\n " , __func__);
390
390
return false ;
391
391
}
392
392
393
393
// check model tensor data layout kv
394
394
keyidx = gguf_find_key (ggufctx, " falcon.tensor_data_layout" );
395
395
if (keyidx != -1 ) {
396
396
if ( strcmp (gguf_get_val_str (ggufctx, keyidx), " jploski" ) != 0 ) {
397
- fprintf (stdout, " %s: model tensor data layout not supported!\n " , __func__);
397
+ printf ( " %s: model tensor data layout not supported!\n " , __func__);
398
398
return false ;
399
399
}
400
400
} else {
401
- fprintf (stdout, " %s: gguf model tensor data layout not found!\n " , __func__);
401
+ printf ( " %s: gguf model tensor data layout not found!\n " , __func__);
402
402
return false ;
403
403
}
404
404
@@ -455,34 +455,34 @@ bool falcon_model_load(const std::string & fname, falcon_model & model, gpt2bpe_
455
455
456
456
if (keyidx != -1 ) {
457
457
if ( strcmp (gguf_get_val_str (ggufctx, keyidx), " gpt2" ) != 0 ) {
458
- fprintf (stdout, " %s: tokenizer model not supported!\n " , __func__);
458
+ printf ( " %s: tokenizer model not supported!\n " , __func__);
459
459
return false ;
460
460
}
461
461
} else {
462
- fprintf (stdout, " %s: tokenizer model not found!\n " , __func__);
462
+ printf ( " %s: tokenizer model not found!\n " , __func__);
463
463
return false ;
464
464
}
465
465
466
466
467
467
int tokens_keyidx = gguf_find_key (ggufctx, " tokenizer.ggml.tokens" );
468
468
469
469
if (tokens_keyidx == -1 ) {
470
- fprintf (stdout, " %s: gpt2 tokenizer vocab not found!\n " , __func__);
470
+ printf ( " %s: gpt2 tokenizer vocab not found!\n " , __func__);
471
471
return false ;
472
472
}
473
473
474
474
int merges_keyidx = gguf_find_key (ggufctx, " tokenizer.ggml.merges" );
475
475
476
476
if (merges_keyidx == -1 ) {
477
- fprintf (stdout, " %s: gpt2 tokenizer merges not found!\n " , __func__);
477
+ printf ( " %s: gpt2 tokenizer merges not found!\n " , __func__);
478
478
return false ;
479
479
}
480
480
481
481
hparams.n_vocab = gguf_get_arr_n (ggufctx,tokens_keyidx);
482
482
hparams.n_merges = gguf_get_arr_n (ggufctx,merges_keyidx);
483
483
484
- fprintf (stdout, " %s: gpt2 tokenizer vocab = %zu\n " , __func__, hparams.n_vocab );
485
- fprintf (stdout, " %s: gpt2 tokenizer merges = %zu\n " , __func__, hparams.n_merges );
484
+ printf ( " %s: gpt2 tokenizer vocab = %zu\n " , __func__, hparams.n_vocab );
485
+ printf ( " %s: gpt2 tokenizer merges = %zu\n " , __func__, hparams.n_merges );
486
486
487
487
for (size_t i = 0 ; i < hparams.n_vocab ; i++) {
488
488
std::string word = gguf_get_arr_str (ggufctx, tokens_keyidx, i);
@@ -523,12 +523,12 @@ bool falcon_model_load(const std::string & fname, falcon_model & model, gpt2bpe_
523
523
keyidx = gguf_find_key (ggufctx, " tokenizer.ggml.separator_token_id" ); if ( keyidx != -1 ) { vocab.special_sep_id = (int32_t )gguf_get_val_u32 (ggufctx, keyidx); }
524
524
keyidx = gguf_find_key (ggufctx, " tokenizer.ggml.padding_token_id" ); if ( keyidx != -1 ) { vocab.special_pad_id = (int32_t )gguf_get_val_u32 (ggufctx, keyidx); }
525
525
526
- if ( vocab.special_bos_id != -1 ) { fprintf (stdout, " %s: BOS token = %d '%s'\n " , __func__, vocab.special_bos_id , vocab.id_to_token [vocab.special_bos_id ].c_str () ); }
527
- if ( vocab.special_eos_id != -1 ) { fprintf (stdout, " %s: EOS token = %d '%s'\n " , __func__, vocab.special_eos_id , vocab.id_to_token [vocab.special_eos_id ].c_str () ); }
528
- if ( vocab.special_unk_id != -1 ) { fprintf (stdout, " %s: UNK token = %d '%s'\n " , __func__, vocab.special_unk_id , vocab.id_to_token [vocab.special_unk_id ].c_str () ); }
529
- if ( vocab.special_sep_id != -1 ) { fprintf (stdout, " %s: SEP token = %d '%s'\n " , __func__, vocab.special_sep_id , vocab.id_to_token [vocab.special_sep_id ].c_str () ); }
530
- if ( vocab.special_pad_id != -1 ) { fprintf (stdout, " %s: PAD token = %d '%s'\n " , __func__, vocab.special_pad_id , vocab.id_to_token [vocab.special_pad_id ].c_str () ); }
531
- if ( vocab.linefeed_id != -1 ) { fprintf (stdout, " %s: LF token = %d\n " , __func__, vocab.linefeed_id ); }
526
+ if ( vocab.special_bos_id != -1 ) { printf ( " %s: BOS token = %d '%s'\n " , __func__, vocab.special_bos_id , vocab.id_to_token [vocab.special_bos_id ].c_str () ); }
527
+ if ( vocab.special_eos_id != -1 ) { printf ( " %s: EOS token = %d '%s'\n " , __func__, vocab.special_eos_id , vocab.id_to_token [vocab.special_eos_id ].c_str () ); }
528
+ if ( vocab.special_unk_id != -1 ) { printf ( " %s: UNK token = %d '%s'\n " , __func__, vocab.special_unk_id , vocab.id_to_token [vocab.special_unk_id ].c_str () ); }
529
+ if ( vocab.special_sep_id != -1 ) { printf ( " %s: SEP token = %d '%s'\n " , __func__, vocab.special_sep_id , vocab.id_to_token [vocab.special_sep_id ].c_str () ); }
530
+ if ( vocab.special_pad_id != -1 ) { printf ( " %s: PAD token = %d '%s'\n " , __func__, vocab.special_pad_id , vocab.id_to_token [vocab.special_pad_id ].c_str () ); }
531
+ if ( vocab.linefeed_id != -1 ) { printf ( " %s: LF token = %d\n " , __func__, vocab.linefeed_id ); }
532
532
533
533
}
534
534
@@ -543,13 +543,13 @@ bool falcon_model_load(const std::string & fname, falcon_model & model, gpt2bpe_
543
543
{
544
544
const int n_tensors = gguf_get_n_tensors(ggufctx);
545
545
546
- fprintf(stdout, "%s: n_tensors: %d\n", __func__, n_tensors);
546
+ printf( "%s: n_tensors: %d\n", __func__, n_tensors);
547
547
548
548
for (int i = 0; i < n_tensors; ++i) {
549
549
const char * name = gguf_get_tensor_name (ggufctx, i);
550
550
const size_t offset = gguf_get_tensor_offset(ggufctx, i);
551
551
552
- fprintf(stdout, "%s: tensor[%d]: name = %s, offset = %zu\n", __func__, i, name, offset);
552
+ printf( "%s: tensor[%d]: name = %s, offset = %zu\n", __func__, i, name, offset);
553
553
}
554
554
}
555
555
#endif
0 commit comments