Fix timesteps of DPMSolverMultistepScheduler. (#88)
There were minor differences in the timesteps because the linspace was computed slightly differently. This PR makes the Swift implementation identical to the current Python implementation in diffusers, which was originally contributed by the DPM-Solver++ author. See https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_dpmsolver_multistep.py#L199-L204 for reference.
This commit is contained in:
parent
e07c4d00c3
commit
e3db2ec99e
|
@ -77,7 +77,7 @@ public final class DPMSolverMultistepScheduler: Scheduler {
|
|||
self.sigma_t = vForce.sqrt(vDSP.subtract([Float](repeating: 1, count: self.alphasCumProd.count), self.alphasCumProd))
|
||||
self.lambda_t = zip(self.alpha_t, self.sigma_t).map { α, σ in log(α) - log(σ) }
|
||||
|
||||
self.timeSteps = linspace(0, Float(self.trainStepCount-1), stepCount).reversed().map { Int(round($0)) }
|
||||
self.timeSteps = linspace(0, Float(self.trainStepCount-1), stepCount+1).dropFirst().reversed().map { Int(round($0)) }
|
||||
}
|
||||
|
||||
/// Convert the model output to the corresponding type the algorithm needs.
|
||||
|
|
Loading…
Reference in New Issue