llama.cpp : print actual model size

This commit is contained in:
klosax 2023-08-17 15:18:16 +02:00 committed by GitHub
parent 42f8fe1927
commit 5a0a2c5685
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1023,6 +1023,7 @@ struct llama_model_loader {
int n_kv = 0; int n_kv = 0;
int n_tensors = 0; int n_tensors = 0;
int n_created = 0; int n_created = 0;
size_t n_tot_elements = 0;
bool use_mmap = false; bool use_mmap = false;
@ -1047,6 +1048,16 @@ struct llama_model_loader {
file_version = (enum llama_file_version) gguf_get_version(ctx_gguf); file_version = (enum llama_file_version) gguf_get_version(ctx_gguf);
for (int i = 0; i < n_tensors; i++) {
const char * name = gguf_get_tensor_name(ctx_gguf, i);
struct ggml_tensor * t = ggml_get_tensor(ctx_meta, name);
size_t elem = 1;
for (int j = 0; j < t->n_dims; j++) {
elem *= t->ne[j];
}
n_tot_elements += elem;
}
// print meta data // print meta data
// TODO: make optional // TODO: make optional
{ {
@ -1413,7 +1424,8 @@ static void llama_model_load_internal(
LLAMA_LOG_INFO("%s: freq_base = %.1f\n", __func__, hparams.rope_freq_base); LLAMA_LOG_INFO("%s: freq_base = %.1f\n", __func__, hparams.rope_freq_base);
LLAMA_LOG_INFO("%s: freq_scale = %g\n", __func__, hparams.rope_freq_scale); LLAMA_LOG_INFO("%s: freq_scale = %g\n", __func__, hparams.rope_freq_scale);
LLAMA_LOG_INFO("%s: ftype = %u (%s)\n", __func__, hparams.ftype, llama_ftype_name(hparams.ftype)); LLAMA_LOG_INFO("%s: ftype = %u (%s)\n", __func__, hparams.ftype, llama_ftype_name(hparams.ftype));
LLAMA_LOG_INFO("%s: model size = %s\n", __func__, llama_model_type_name(model.type)); LLAMA_LOG_INFO("%s: model size = %.2f B\n", __func__, ml->n_tot_elements*1e-9);
} }
if (vocab_only) { if (vocab_only) {