fix: correct the handling of weight loading

This commit is contained in:
leejet
2023-08-30 21:44:06 +08:00
parent 1b5a868296
commit c542a77a3f
2 changed files with 23 additions and 9 deletions

View File

@@ -2864,6 +2864,8 @@ class StableDiffusionGGML {
nelements *= ne[i];
}
const size_t num_bytes = nelements / ggml_blck_size(ggml_type(ttype)) * ggml_type_size(ggml_type(ttype));
std::string name(length, 0);
file.read(&name[0], length);
@@ -2891,7 +2893,7 @@ class StableDiffusionGGML {
return false;
}
}
file.ignore(nelements * ggml_type_size((ggml_type)ttype));
file.ignore(num_bytes);
continue;
}
@@ -2919,8 +2921,6 @@ class StableDiffusionGGML {
return false;
}
const size_t num_bytes = nelements / ggml_blck_size(ggml_type(ttype)) * ggml_type_size(ggml_type(ttype));
file.read(reinterpret_cast<char*>(tensor->data), num_bytes);
total_size += ggml_nbytes(tensor);