|
18 | 18 | #include "rng_philox.h" |
19 | 19 | #include "stable-diffusion.h" |
20 | 20 |
|
| 21 | +#define EPS 1e-05 |
| 22 | + |
21 | 23 | static SDLogLevel log_level = SDLogLevel::INFO; |
22 | 24 |
|
23 | 25 | #define __FILENAME__ "stable-diffusion.cpp" |
@@ -586,7 +588,7 @@ struct ResidualAttentionBlock { |
586 | 588 |
|
587 | 589 | // layer norm 1 |
588 | 590 | { |
589 | | - x = ggml_norm(ctx, x, 1e-6f); |
| 591 | + x = ggml_norm(ctx, x, EPS); |
590 | 592 | x = ggml_add(ctx, |
591 | 593 | ggml_mul(ctx, ggml_repeat(ctx, ln1_w, x), x), |
592 | 594 | ggml_repeat(ctx, ln1_b, x)); |
@@ -636,7 +638,7 @@ struct ResidualAttentionBlock { |
636 | 638 |
|
637 | 639 | // layer norm 2 |
638 | 640 | { |
639 | | - x = ggml_norm(ctx, x, 1e-6f); |
| 641 | + x = ggml_norm(ctx, x, EPS); |
640 | 642 |
|
641 | 643 | x = ggml_add(ctx, ggml_mul(ctx, ggml_repeat(ctx, ln2_w, x), x), |
642 | 644 | ggml_repeat(ctx, ln2_b, x)); |
@@ -766,7 +768,7 @@ struct CLIPTextModel { |
766 | 768 |
|
767 | 769 | // final layer norm |
768 | 770 | { |
769 | | - x = ggml_norm(ctx, x, 1e-6f); |
| 771 | + x = ggml_norm(ctx, x, EPS); |
770 | 772 |
|
771 | 773 | x = ggml_add(ctx, ggml_mul(ctx, ggml_repeat(ctx, final_ln_w, x), x), |
772 | 774 | ggml_repeat(ctx, final_ln_b, x)); |
@@ -1200,7 +1202,7 @@ struct SpatialTransformer { |
1200 | 1202 | // layer norm 1 |
1201 | 1203 | { |
1202 | 1204 | x = ggml_reshape_2d(ctx, x, c, w * h * n); |
1203 | | - x = ggml_norm(ctx, x, 1e-6f); |
| 1205 | + x = ggml_norm(ctx, x, EPS); |
1204 | 1206 | x = ggml_add(ctx, |
1205 | 1207 | ggml_mul(ctx, |
1206 | 1208 | ggml_repeat(ctx, transformer.norm1_w, x), |
@@ -1248,7 +1250,7 @@ struct SpatialTransformer { |
1248 | 1250 |
|
1249 | 1251 | // layer norm 2 |
1250 | 1252 | { |
1251 | | - x = ggml_norm(ctx, x, 1e-6f); |
| 1253 | + x = ggml_norm(ctx, x, EPS); |
1252 | 1254 | x = ggml_add(ctx, |
1253 | 1255 | ggml_mul(ctx, |
1254 | 1256 | ggml_repeat(ctx, transformer.norm2_w, x), x), |
@@ -1299,7 +1301,7 @@ struct SpatialTransformer { |
1299 | 1301 | // layer norm 3 |
1300 | 1302 | { |
1301 | 1303 | x = ggml_reshape_2d(ctx, x, c, h * w * n); // [N * h * w, in_channels] |
1302 | | - x = ggml_norm(ctx, x, 1e-6f); |
| 1304 | + x = ggml_norm(ctx, x, EPS); |
1303 | 1305 | x = ggml_add(ctx, |
1304 | 1306 | ggml_mul(ctx, |
1305 | 1307 | ggml_repeat(ctx, transformer.norm3_w, x), x), |
|
0 commit comments