2024-05-23 21:16:26 +00:00
|
|
|
From 544a2d2e646d39e878d87dfbb3398a356bc560ab Mon Sep 17 00:00:00 2001
|
|
|
|
From: Michael Yang <mxyng@pm.me>
|
|
|
|
Date: Thu, 23 May 2024 11:18:45 -0700
|
|
|
|
Subject: [PATCH] throw exception on load errors
|
|
|
|
|
|
|
|
---
|
|
|
|
llama.cpp | 25 ++++++++++++++++---------
|
|
|
|
1 file changed, 16 insertions(+), 9 deletions(-)
|
|
|
|
|
2024-03-11 20:48:27 +00:00
|
|
|
diff --git a/llama.cpp b/llama.cpp
|
2024-05-23 21:16:26 +00:00
|
|
|
index 15c66077..8ba90b6a 100644
|
2024-03-11 20:48:27 +00:00
|
|
|
--- a/llama.cpp
|
|
|
|
+++ b/llama.cpp
|
2024-05-23 21:16:26 +00:00
|
|
|
@@ -6346,7 +6346,7 @@ static int llama_model_load(const std::string & fname, llama_model & model, llam
|
2024-03-11 20:48:27 +00:00
|
|
|
}
|
|
|
|
} catch (const std::exception & err) {
|
|
|
|
LLAMA_LOG_ERROR("%s: error loading model: %s\n", __func__, err.what());
|
|
|
|
- return -1;
|
|
|
|
+ throw;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2024-05-23 21:16:26 +00:00
|
|
|
@@ -15600,16 +15600,23 @@ struct llama_model * llama_load_model_from_file(
|
|
|
|
}
|
|
|
|
model->rpc_servers.push_back(servers);
|
2024-03-11 20:48:27 +00:00
|
|
|
}
|
|
|
|
- int status = llama_model_load(path_model, *model, params);
|
|
|
|
- GGML_ASSERT(status <= 0);
|
|
|
|
- if (status < 0) {
|
|
|
|
- if (status == -1) {
|
|
|
|
- LLAMA_LOG_ERROR("%s: failed to load model\n", __func__);
|
|
|
|
- } else if (status == -2) {
|
|
|
|
- LLAMA_LOG_INFO("%s: cancelled model load\n", __func__);
|
2024-05-23 21:16:26 +00:00
|
|
|
+
|
2024-03-11 20:48:27 +00:00
|
|
|
+ try {
|
|
|
|
+ int status = llama_model_load(path_model, *model, params);
|
|
|
|
+ GGML_ASSERT(status <= 0);
|
|
|
|
+ if (status < 0) {
|
|
|
|
+ if (status == -1) {
|
|
|
|
+ LLAMA_LOG_ERROR("%s: failed to load model\n", __func__);
|
|
|
|
+ } else if (status == -2) {
|
|
|
|
+ LLAMA_LOG_INFO("%s: cancelled model load\n", __func__);
|
|
|
|
+ }
|
|
|
|
+ delete model;
|
|
|
|
+ return nullptr;
|
|
|
|
}
|
|
|
|
+ } catch (...) {
|
|
|
|
+ LLAMA_LOG_ERROR("%s: exception loading model\n", __func__);
|
|
|
|
delete model;
|
|
|
|
- return nullptr;
|
|
|
|
+ throw;
|
|
|
|
}
|
|
|
|
|
|
|
|
return model;
|
2024-05-23 21:16:26 +00:00
|
|
|
--
|
|
|
|
2.45.1
|
|
|
|
|