Skip to content

Commit 694f0d9

Browse files
authored
refactor: optimize the logic for name conversion and the processing of the LoRA model (#955)
1 parent 8ecdf05 commit 694f0d9

20 files changed

+1640
-1385
lines changed

conditioner.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ struct FrozenCLIPEmbedderWithCustomWords : public Conditioner {
111111
bool load_embedding(std::string embd_name, std::string embd_path, std::vector<int32_t>& bpe_tokens) {
112112
// the order matters
113113
ModelLoader model_loader;
114-
if (!model_loader.init_from_file(embd_path)) {
114+
if (!model_loader.init_from_file_and_convert_name(embd_path)) {
115115
LOG_ERROR("embedding '%s' failed", embd_name.c_str());
116116
return false;
117117
}

control.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ struct ControlNet : public GGMLRunner {
442442
std::set<std::string> ignore_tensors;
443443

444444
ModelLoader model_loader;
445-
if (!model_loader.init_from_file(file_path)) {
445+
if (!model_loader.init_from_file_and_convert_name(file_path)) {
446446
LOG_ERROR("init control net model loader from file failed: '%s'", file_path.c_str());
447447
return false;
448448
}

esrgan.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ struct ESRGAN : public GGMLRunner {
169169
LOG_INFO("loading esrgan from '%s'", file_path.c_str());
170170

171171
ModelLoader model_loader;
172-
if (!model_loader.init_from_file(file_path)) {
172+
if (!model_loader.init_from_file_and_convert_name(file_path)) {
173173
LOG_ERROR("init esrgan model loader from file failed: '%s'", file_path.c_str());
174174
return false;
175175
}

flux.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,7 @@ namespace Flux {
13981398
ggml_type model_data_type = GGML_TYPE_Q8_0;
13991399

14001400
ModelLoader model_loader;
1401-
if (!model_loader.init_from_file(file_path, "model.diffusion_model.")) {
1401+
if (!model_loader.init_from_file_and_convert_name(file_path, "model.diffusion_model.")) {
14021402
LOG_ERROR("init model loader from file failed: '%s'", file_path.c_str());
14031403
return;
14041404
}

ggml_extend.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,8 +1568,10 @@ struct GGMLRunner {
15681568
struct ggml_cgraph* get_compute_graph(get_graph_cb_t get_graph) {
15691569
prepare_build_in_tensor_before();
15701570
struct ggml_cgraph* gf = get_graph();
1571-
auto result = ggml_graph_node(gf, -1);
1572-
ggml_set_name(result, final_result_name.c_str());
1571+
if (ggml_graph_n_nodes(gf) > 0) {
1572+
auto result = ggml_graph_node(gf, -1);
1573+
ggml_set_name(result, final_result_name.c_str());
1574+
}
15731575
prepare_build_in_tensor_after(gf);
15741576
return gf;
15751577
}

0 commit comments

Comments
 (0)