From f9f0d4685b4f13bb44a6c2214981efe0a304dc13 Mon Sep 17 00:00:00 2001 From: leejet Date: Mon, 10 Jun 2024 23:04:02 +0800 Subject: [PATCH] fix: sample_k_diffusion should be static --- denoiser.hpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/denoiser.hpp b/denoiser.hpp index 6ecb618..a55c430 100644 --- a/denoiser.hpp +++ b/denoiser.hpp @@ -263,14 +263,13 @@ struct CompVisVDenoiser : public Denoiser { typedef std::function denoise_cb_t; - // k diffusion reverse ODE: dx = (x - D(x;\sigma)) / \sigma dt; \sigma(t) = t -void sample_k_diffusion(sample_method_t method, - denoise_cb_t model, - ggml_context* work_ctx, - ggml_tensor* x, - std::vector sigmas, - std::shared_ptr rng) { +static void sample_k_diffusion(sample_method_t method, + denoise_cb_t model, + ggml_context* work_ctx, + ggml_tensor* x, + std::vector sigmas, + std::shared_ptr rng) { size_t steps = sigmas.size() - 1; // sample_euler_ancestral switch (method) { @@ -401,7 +400,7 @@ void sample_k_diffusion(sample_method_t method, } ggml_tensor* denoised = model(x2, sigmas[i + 1], i + 1); - float* vec_denoised = (float*)denoised->data; + float* vec_denoised = (float*)denoised->data; for (int j = 0; j < ggml_nelements(x); j++) { float d2 = (vec_x2[j] - vec_denoised[j]) / sigmas[i + 1]; vec_d[j] = (vec_d[j] + d2) / 2; @@ -453,7 +452,7 @@ void sample_k_diffusion(sample_method_t method, } ggml_tensor* denoised = model(x2, sigma_mid, i + 1); - float* vec_denoised = (float*)denoised->data; + float* vec_denoised = (float*)denoised->data; for (int j = 0; j < ggml_nelements(x); j++) { float d2 = (vec_x2[j] - vec_denoised[j]) / sigma_mid; vec_x[j] = vec_x[j] + d2 * dt_2;