]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
ci : fix and re-enable tests (2nd try)
authorGeorgi Gerganov <redacted>
Fri, 21 Oct 2022 12:57:20 +0000 (15:57 +0300)
committerGeorgi Gerganov <redacted>
Fri, 21 Oct 2022 12:57:20 +0000 (15:57 +0300)
CMakeLists.txt
whisper.cpp

index c1cdd437d79e7d2c5b9d18ce03ba91c1b56e3187..85b9458dcdc9b78a0f05beab47c5460dbb1bee2c 100644 (file)
@@ -170,9 +170,8 @@ if (WHISPER_STANDALONE)
         target_link_libraries(${TARGET} PRIVATE whisper ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
     endif ()
 
-    # TODO: temporary disabled
-    #if (WHISPER_BUILD_TESTS)
-    #    enable_testing()
-    #    add_subdirectory(tests)
-    #endif ()
+    if (WHISPER_BUILD_TESTS)
+        enable_testing()
+        add_subdirectory(tests)
+    endif ()
 endif ()
index 2d2b8cedcb173644b4153dba698911dfac216a75..09250c06755ba96bd786836b958f755e8a0aee1e 100644 (file)
@@ -379,8 +379,11 @@ struct whisper_model {
     struct ggml_tensor * memory_cross_k;
     struct ggml_tensor * memory_cross_v;
 
-    //
+    // context
     struct ggml_context * ctx;
+
+    // tensors
+    int n_loaded;
     std::map<std::string, struct ggml_tensor *> tensors;
 };
 
@@ -951,9 +954,10 @@ bool whisper_model_load(const std::string & fname, whisper_context & wctx) {
 
     // load weights
     {
-        int n_loaded = 0;
         size_t total_size = 0;
 
+        model.n_loaded = 0;
+
         while (true) {
             int32_t n_dims;
             int32_t length;
@@ -1006,15 +1010,15 @@ bool whisper_model_load(const std::string & fname, whisper_context & wctx) {
 
             //printf("%24s - [%5d, %5d], type = %6s, %6.2f MB\n", name.data(), ne[0], ne[1], ftype == 0 ? "float" : "f16", ggml_nbytes(tensor)/1024.0/1024.0);
             total_size += ggml_nbytes(tensor);
-            n_loaded++;
+            model.n_loaded++;
         }
 
         fprintf(stderr, "%s: model size  = %8.2f MB\n", __func__, total_size/1024.0/1024.0);
 
-        if (n_loaded == 0) {
+        if (model.n_loaded == 0) {
             fprintf(stderr, "%s: WARN no tensors loaded from model file - assuming empty model for testing\n", __func__);
-        } else if (n_loaded != (int) model.tensors.size()) {
-            fprintf(stderr, "%s: ERROR not all tensors loaded from model file - expected %zu, got %d\n", __func__, model.tensors.size(), n_loaded);
+        } else if (model.n_loaded != (int) model.tensors.size()) {
+            fprintf(stderr, "%s: ERROR not all tensors loaded from model file - expected %zu, got %d\n", __func__, model.tensors.size(), model.n_loaded);
             return false;
         }
     }
@@ -2477,6 +2481,12 @@ int whisper_full(
                     }
                     break;
                 }
+
+                // TESTS: if no tensors are loaded, it means we are running tests
+                if (ctx->model.n_loaded == 0) {
+                    seek_delta = 100*WHISPER_CHUNK_SIZE;
+                    break;
+                }
             }
 
             if (done) {