Skip to content

Commit 90e9178

Browse files
bssrdfbssrdf
and
bssrdf
authored
fix: apply pmid lora only once for multiple txt2img calls (#208)
Co-authored-by: bssrdf <[email protected]>
1 parent 48bcce4 commit 90e9178

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lora.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ struct LoraModel : public GGMLModule {
1111
std::string file_path;
1212
ModelLoader model_loader;
1313
bool load_failed = false;
14+
bool applied = false;
1415

1516
LoraModel(ggml_backend_t backend,
1617
ggml_type wtype,

stable-diffusion.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1607,10 +1607,11 @@ sd_image_t* txt2img(sd_ctx_t* sd_ctx,
16071607
int64_t t1 = ggml_time_ms();
16081608
LOG_INFO("apply_loras completed, taking %.2fs", (t1 - t0) * 1.0f / 1000);
16091609

1610-
if (sd_ctx->sd->stacked_id) {
1610+
if (sd_ctx->sd->stacked_id && !sd_ctx->sd->pmid_lora->applied) {
16111611
t0 = ggml_time_ms();
16121612
sd_ctx->sd->pmid_lora->apply(sd_ctx->sd->tensors, sd_ctx->sd->n_threads);
16131613
t1 = ggml_time_ms();
1614+
sd_ctx->sd->pmid_lora->applied = true;
16141615
LOG_INFO("pmid_lora apply completed, taking %.2fs", (t1 - t0) * 1.0f / 1000);
16151616
if (sd_ctx->sd->free_params_immediately) {
16161617
sd_ctx->sd->pmid_lora->free_params_buffer();

0 commit comments

Comments
 (0)