From fd098afc6dc2f284f1b6fda39c912df71854fdaf Mon Sep 17 00:00:00 2001 From: bssrdf Date: Tue, 27 Feb 2024 14:49:39 -0500 Subject: [PATCH] bring back freeing pmid lora params buffer; simply pooled output of CLIPvision --- clip.hpp | 8 ++++---- stable-diffusion.cpp | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/clip.hpp b/clip.hpp index fc171aec..75d6de28 100644 --- a/clip.hpp +++ b/clip.hpp @@ -904,10 +904,10 @@ public: GGML_ASSERT(x->ne[3] == 1); // int64_t max_token_idx = 0; // ggml_tensor* pooled = ggml_view_1d(ctx, x, x->ne[0], x->nb[1] * max_token_idx); // assert N == 1 - x = ggml_cont(ctx, ggml_permute(ctx, x, 0, 2, 1, 3)); - ggml_tensor* pooled = ggml_view_2d(ctx, x, x->ne[0], x->ne[1], x->nb[0], 0); - pooled = ggml_scale(ctx, ggml_cont(ctx, pooled), 1.f); - // print_ggml_tensor(pooled, true, "pooled"); + // x = ggml_cont(ctx, ggml_permute(ctx, x, 0, 2, 1, 3)); + // ggml_tensor* pooled = ggml_view_2d(ctx, x, x->ne[0], x->ne[1], x->nb[0], 0); + // pooled = ggml_cont(ctx, pooled); + ggml_tensor* pooled = ggml_cont(ctx, ggml_view_2d(ctx, x, x->ne[0], x->ne[2], x->nb[2], 0)); return pooled; // [N, projection_dim] } diff --git a/stable-diffusion.cpp b/stable-diffusion.cpp index 9f2bbead..5708af44 100644 --- a/stable-diffusion.cpp +++ b/stable-diffusion.cpp @@ -1641,13 +1641,13 @@ sd_image_t* txt2img(sd_ctx_t* sd_ctx, LOG_INFO("apply_loras completed, taking %.2fs", (t1 - t0) * 1.0f / 1000); if(sd_ctx->sd->stacked_id){ - // sd_ctx->sd->pmid_lora.apply(sd_ctx->sd->tensors, sd_ctx->sd->n_threads); + t0 = ggml_time_ms(); sd_ctx->sd->pmid_lora->apply(sd_ctx->sd->tensors, sd_ctx->sd->n_threads); - // sd_ctx->sd->pmid_lora.free_compute_buffer(); - // if (sd_ctx->sd->free_params_immediately) { - // sd_ctx->sd->pmid_lora.free_params_buffer(); - // } - LOG_INFO("pmid_lora apply completed"); + t1 = ggml_time_ms(); + 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(); + } } struct ggml_init_params params;