ci : fix and re-enable tests (2nd try)

This commit is contained in:
Georgi Gerganov 2022-10-21 15:57:20 +03:00
parent 692aa0784f
commit 8d15a1c635
No known key found for this signature in database
GPG Key ID: 449E073F9DC10735
2 changed files with 20 additions and 11 deletions

View File

@ -170,9 +170,8 @@ if (WHISPER_STANDALONE)
target_link_libraries(${TARGET} PRIVATE whisper ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(${TARGET} PRIVATE whisper ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
endif () endif ()
# TODO: temporary disabled if (WHISPER_BUILD_TESTS)
#if (WHISPER_BUILD_TESTS) enable_testing()
# enable_testing() add_subdirectory(tests)
# add_subdirectory(tests) endif ()
#endif ()
endif () endif ()

View File

@ -379,8 +379,11 @@ struct whisper_model {
struct ggml_tensor * memory_cross_k; struct ggml_tensor * memory_cross_k;
struct ggml_tensor * memory_cross_v; struct ggml_tensor * memory_cross_v;
// // context
struct ggml_context * ctx; struct ggml_context * ctx;
// tensors
int n_loaded;
std::map<std::string, struct ggml_tensor *> tensors; 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 // load weights
{ {
int n_loaded = 0;
size_t total_size = 0; size_t total_size = 0;
model.n_loaded = 0;
while (true) { while (true) {
int32_t n_dims; int32_t n_dims;
int32_t length; 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); //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); 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); 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__); 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()) { } 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(), n_loaded); 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; return false;
} }
} }
@ -2477,6 +2481,12 @@ int whisper_full(
} }
break; 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) { if (done) {