Skip to content

Commit 34a118d

Browse files
committed
fix: avoid coredump when steps == 1
1 parent f6ff06f commit 34a118d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

stable-diffusion.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2659,10 +2659,19 @@ struct DiscreteSchedule {
26592659
float sigmas[TIMESTEPS];
26602660
float log_sigmas[TIMESTEPS];
26612661

2662-
std::vector<float> get_sigmas(int n) {
2662+
std::vector<float> get_sigmas(uint32_t n) {
26632663
std::vector<float> result;
26642664

26652665
int t_max = TIMESTEPS - 1;
2666+
2667+
if (n == 0) {
2668+
return result;
2669+
} else if (n == 1) {
2670+
result.push_back(t_to_sigma(t_max));
2671+
result.push_back(0);
2672+
return result;
2673+
}
2674+
26662675
float step = static_cast<float>(t_max) / static_cast<float>(n - 1);
26672676
for (int i = 0; i < n; ++i) {
26682677
float t = t_max - step * i;

0 commit comments

Comments
 (0)