File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -1558,6 +1558,10 @@ class StableDiffusionGGML {
15581558 }
15591559 }
15601560
1561+ if (ucache_enabled) {
1562+ ucache_state.set_sigmas (sigmas);
1563+ }
1564+
15611565 size_t steps = sigmas.size () - 1 ;
15621566 struct ggml_tensor * x = ggml_dup_tensor (work_ctx, init_latent);
15631567 copy_ggml_tensor (x, init_latent);
Original file line number Diff line number Diff line change @@ -126,6 +126,26 @@ struct UCacheState {
126126 }
127127 }
128128
129+ void set_sigmas (const std::vector<float >& sigmas) {
130+ if (!initialized || sigmas.size () < 2 ) {
131+ return ;
132+ }
133+ size_t n_steps = sigmas.size () - 1 ;
134+
135+ size_t start_step = static_cast <size_t >(config.start_percent * n_steps);
136+ size_t end_step = static_cast <size_t >(config.end_percent * n_steps);
137+
138+ if (start_step >= n_steps) start_step = n_steps - 1 ;
139+ if (end_step >= n_steps) end_step = n_steps - 1 ;
140+
141+ start_sigma = sigmas[start_step];
142+ end_sigma = sigmas[end_step];
143+
144+ if (start_sigma < end_sigma) {
145+ std::swap (start_sigma, end_sigma);
146+ }
147+ }
148+
129149 bool enabled () const {
130150 return initialized && config.enabled ;
131151 }
You can’t perform that action at this time.
0 commit comments