Liu Song’s Projects


~/Projects/whisper.cpp

git clone https://code.lsong.org/whisper.cpp

Commit

Commit
128aaadb93a731a6bc960f8c4aa988046e9ee975
Author
Georgi Gerganov <[email protected]>
Date
2022-11-24 17:54:16 +0200 +0200
Diffstat
 whisper.cpp | 29 ++++++++++++++++-------------

whisper : improve printfs


diff --git a/whisper.cpp b/whisper.cpp
index d729dba52181ae4e68acbf98276480ed4561ff0f..aab743e34bfcb738d8c8b941bca07a0e70a73cc5 100644
--- a/whisper.cpp
+++ b/whisper.cpp
@@ -518,15 +518,6 @@         wctx.buf_model->resize(MEM_REQ_MODEL.at(model.type));
         wctx.buf_memory.resize(MEM_REQ_MEMORY.at(model.type));
         wctx.buf_compute.resize(std::max(MEM_REQ_ENCODE.at(model.type), MEM_REQ_DECODE.at(model.type)));
         wctx.buf_compute_layer.resize(std::max(MEM_REQ_ENCODE_LAYER.at(model.type), MEM_REQ_DECODE_LAYER.at(model.type)));
-
-        // this is the total memory required to run the inference
-        const size_t mem_required =
-                   wctx.buf_model->size() +
-                   wctx.buf_memory.size() +
-                   wctx.buf_compute.size() +
-                   wctx.buf_compute_layer.size();
-
-        fprintf(stderr, "%s: mem_required  = %.2f MB\n", __func__, mem_required / 1024.0 / 1024.0);
     }
 
     // load mel filters
@@ -599,10 +590,20 @@             }
         }
     }
 
+    {
+        // this is the total memory required to run the inference
+        const size_t mem_required =
+                   wctx.buf_model->size() +
+                   wctx.buf_memory.size() +
+                   wctx.buf_compute.size() +
+                   wctx.buf_compute_layer.size();
+
+        fprintf(stderr, "%s: mem_required  = %7.2f MB\n", __func__, mem_required / 1024.0 / 1024.0);
+    }
+
     // for the big tensors, we have the option to store the data in 16-bit floats
     // in order to save memory and also to speed up the computation
     const ggml_type wtype = model.hparams.f16 ? GGML_TYPE_F16 : GGML_TYPE_F32;
-
 
     size_t ctx_size = 0;
     size_t ctx_mem_size = 0;
@@ -722,7 +723,7 @@         ctx_mem_size += n_text_layer*n_audio_ctx*n_text_state*ggml_type_size(GGML_TYPE_F16); // memory_cross_v
 
         ctx_size += (15 + 15*n_audio_layer + 24*n_text_layer)*256; // object overhead
 
-        fprintf(stderr, "%s: ggml ctx size = %6.2f MB\n", __func__, ctx_size/(1024.0*1024.0));
+        fprintf(stderr, "%s: ggml ctx size = %7.2f MB\n", __func__, ctx_size/(1024.0*1024.0));
     }
 
     // create the ggml context
@@ -983,8 +984,9 @@         const size_t memory_size =
             ggml_nbytes(model.memory_k)       + ggml_nbytes(model.memory_v) +
             ggml_nbytes(model.memory_cross_k) + ggml_nbytes(model.memory_cross_v);
 
-    { "cy",  { 38,  "welsh",          } },
+// available whisper models
 #define _USE_MATH_DEFINES
+#include "ggml.h"
     }
 
     // load weights
@@ -1048,8 +1050,9 @@             total_size += ggml_nbytes(tensor);
             model.n_loaded++;
         }
 
+// available whisper models
 #define _USE_MATH_DEFINES
-#include "ggml.h"
+#include <algorithm>
 
         if (model.n_loaded == 0) {
             fprintf(stderr, "%s: WARN no tensors loaded from model file - assuming empty model for testing\n", __func__);