Skip to content

Commit

Permalink
fix: apply pmid lora only once for multiple txt2img calls (#208)
Browse files Browse the repository at this point in the history
Co-authored-by: bssrdf <bssrdf@gmail.com>
  • Loading branch information
bssrdf and bssrdf authored Apr 2, 2024
1 parent 48bcce4 commit 90e9178
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions lora.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct LoraModel : public GGMLModule {
std::string file_path;
ModelLoader model_loader;
bool load_failed = false;
bool applied = false;

LoraModel(ggml_backend_t backend,
ggml_type wtype,
Expand Down
3 changes: 2 additions & 1 deletion stable-diffusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1607,10 +1607,11 @@ sd_image_t* txt2img(sd_ctx_t* sd_ctx,
int64_t t1 = ggml_time_ms();
LOG_INFO("apply_loras completed, taking %.2fs", (t1 - t0) * 1.0f / 1000);

if (sd_ctx->sd->stacked_id) {
if (sd_ctx->sd->stacked_id && !sd_ctx->sd->pmid_lora->applied) {
t0 = ggml_time_ms();
sd_ctx->sd->pmid_lora->apply(sd_ctx->sd->tensors, sd_ctx->sd->n_threads);
t1 = ggml_time_ms();
sd_ctx->sd->pmid_lora->applied = true;
LOG_INFO("pmid_lora apply completed, taking %.2fs", (t1 - t0) * 1.0f / 1000);
if (sd_ctx->sd->free_params_immediately) {
sd_ctx->sd->pmid_lora->free_params_buffer();
Expand Down

0 comments on commit 90e9178

Please sign in to comment.