Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit97ad3e7

Browse files
authored
refactor: simplify DPM++ (2S) Ancestral (leejet#667)
1 parent8909523 commit97ad3e7

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

‎denoiser.hpp‎

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,6 @@ static void sample_k_diffusion(sample_method_t method,
770770
}break;
771771
case DPMPP2S_A: {
772772
structggml_tensor* noise =ggml_dup_tensor(work_ctx, x);
773-
structggml_tensor* d =ggml_dup_tensor(work_ctx, x);
774773
structggml_tensor* x2 =ggml_dup_tensor(work_ctx, x);
775774

776775
for (int i =0; i < steps; i++) {
@@ -785,22 +784,15 @@ static void sample_k_diffusion(sample_method_t method,
785784
auto sigma_fn = [](float t) ->float {returnexp(-t); };
786785

787786
if (sigma_down ==0) {
788-
// Euler step
789-
float* vec_d = (float*)d->data;
787+
// d = (x - denoised) / sigmas[i];
788+
// dt = sigma_down - sigmas[i];
789+
// x += d * dt;
790+
// => x = denoised
790791
float* vec_x = (float*)x->data;
791792
float* vec_denoised = (float*)denoised->data;
792793

793-
for (int j =0; j <ggml_nelements(d); j++) {
794-
vec_d[j] = (vec_x[j] - vec_denoised[j]) / sigmas[i];
795-
}
796-
797-
// TODO: If sigma_down == 0, isn't this wrong?
798-
// But
799-
// https://github.com/crowsonkb/k-diffusion/blob/master/k_diffusion/sampling.py#L525
800-
// has this exactly the same way.
801-
float dt = sigma_down - sigmas[i];
802-
for (int j =0; j <ggml_nelements(d); j++) {
803-
vec_x[j] = vec_x[j] + vec_d[j] * dt;
794+
for (int j =0; j <ggml_nelements(x); j++) {
795+
vec_x[j] = vec_denoised[j];
804796
}
805797
}else {
806798
// DPM-Solver++(2S)
@@ -809,7 +801,6 @@ static void sample_k_diffusion(sample_method_t method,
809801
float h = t_next - t;
810802
float s = t +0.5f * h;
811803

812-
float* vec_d = (float*)d->data;
813804
float* vec_x = (float*)x->data;
814805
float* vec_x2 = (float*)x2->data;
815806
float* vec_denoised = (float*)denoised->data;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp