mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-01-02 18:53:36 +00:00
fix: added a clean exit in ModelLoader::load_tensors if OOM (#1097)
This commit is contained in:
parent
e687913bf1
commit
a23262dfde
@ -862,7 +862,7 @@ static bool is_absolute_path(const std::string& p) {
|
|||||||
|
|
||||||
struct SDGenerationParams {
|
struct SDGenerationParams {
|
||||||
std::string prompt;
|
std::string prompt;
|
||||||
std::string prompt_with_lora; // for metadata record only
|
std::string prompt_with_lora; // for metadata record only
|
||||||
std::string negative_prompt;
|
std::string negative_prompt;
|
||||||
int clip_skip = -1; // <= 0 represents unspecified
|
int clip_skip = -1; // <= 0 represents unspecified
|
||||||
int width = 512;
|
int width = 512;
|
||||||
|
|||||||
@ -1520,6 +1520,11 @@ bool ModelLoader::load_tensors(on_new_tensor_cb_t on_new_tensor_cb, int n_thread
|
|||||||
i64_to_i32_vec((int64_t*)read_buf, (int32_t*)target_buf, tensor_storage.nelements());
|
i64_to_i32_vec((int64_t*)read_buf, (int32_t*)target_buf, tensor_storage.nelements());
|
||||||
}
|
}
|
||||||
if (tensor_storage.type != dst_tensor->type) {
|
if (tensor_storage.type != dst_tensor->type) {
|
||||||
|
if (convert_buf == nullptr) {
|
||||||
|
LOG_ERROR("read tensor data failed: too less memory for conversion");
|
||||||
|
failed = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
convert_tensor((void*)target_buf,
|
convert_tensor((void*)target_buf,
|
||||||
tensor_storage.type,
|
tensor_storage.type,
|
||||||
convert_buf,
|
convert_buf,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user