MCPcopy Create free account
hub / github.com/PABannier/bark.cpp / bark_model_load

Function bark_model_load

bark.cpp:699–1089  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

697}
698
699static bool bark_model_load(std::ifstream& fin, gpt_model& model, int n_gpu_layers, bark_verbosity_level verbosity) {
700 // load hparams
701 {
702 auto& hparams = model.hparams;
703
704 read_safe(fin, hparams.n_layer);
705 read_safe(fin, hparams.n_head);
706 read_safe(fin, hparams.n_embd);
707 read_safe(fin, hparams.block_size);
708 read_safe(fin, hparams.bias);
709 read_safe(fin, hparams.n_in_vocab);
710 read_safe(fin, hparams.n_out_vocab);
711 read_safe(fin, hparams.n_lm_heads);
712 read_safe(fin, hparams.n_wtes);
713 read_safe(fin, hparams.ftype);
714
715 const int32_t qntvr = hparams.ftype / GGML_QNT_VERSION_FACTOR;
716
717 if (verbosity == bark_verbosity_level::MEDIUM || verbosity == bark_verbosity_level::HIGH) {
718 printf("%s: n_in_vocab = %d\n", __func__, hparams.n_in_vocab);
719 printf("%s: n_out_vocab = %d\n", __func__, hparams.n_out_vocab);
720 printf("%s: block_size = %d\n", __func__, hparams.block_size);
721 printf("%s: bias = %d\n", __func__, hparams.bias);
722 printf("%s: n_embd = %d\n", __func__, hparams.n_embd);
723 printf("%s: n_head = %d\n", __func__, hparams.n_head);
724 printf("%s: n_layer = %d\n", __func__, hparams.n_layer);
725 printf("%s: n_lm_heads = %d\n", __func__, hparams.n_lm_heads);
726 printf("%s: n_wtes = %d\n", __func__, hparams.n_wtes);
727 printf("%s: ftype = %d\n", __func__, hparams.ftype);
728 printf("%s: qntvr = %d\n", __func__, qntvr);
729 }
730
731 hparams.ftype %= GGML_QNT_VERSION_FACTOR;
732 }
733
734 // for the big tensors, we have the option to store the data in 16-bit floats or quantized
735 // in order to save memory and also to speed up the computation
736 ggml_type wtype = ggml_ftype_to_ggml_type((ggml_ftype)(model.hparams.ftype));
737 if (wtype == GGML_TYPE_COUNT) {
738 fprintf(stderr, "%s: invalid model file (bad ftype value %d)\n",
739 __func__, model.hparams.ftype);
740 return false;
741 }
742
743 auto& ctx = model.ctx;
744
745 size_t buffer_size = 0;
746 size_t n_tensors = 0;
747
748 // Evaluating context size
749 {
750 const auto& hparams = model.hparams;
751
752 const int n_embd = hparams.n_embd;
753 const int n_layer = hparams.n_layer;
754 const int block_size = hparams.block_size;
755 const int n_in_vocab = hparams.n_in_vocab;
756 const int n_out_vocab = hparams.n_out_vocab;

Callers 1

Calls 5

readMethod · 0.80
dataMethod · 0.80
endMethod · 0.80
read_safeFunction · 0.70
to_stringFunction · 0.50

Tested by

no test coverage detected