@@ -142,6 +142,12 @@ impl DPMSolverSinglestepScheduler {
142142 ///
143143 /// Note that the algorithm type and the model type is decoupled. That is to say, we can use either DPM-Solver or
144144 /// DPM-Solver++ for both noise prediction model and data prediction model.
145+ ///
146+ /// # Arguments
147+ ///
148+ /// * `model_output` - direct output from learned diffusion mode
149+ /// * `timestep` - current discrete timestep in the diffusion chain
150+ /// * `sample` - current instance of sample being created by diffusion process
145151 fn convert_model_output (
146152 & self ,
147153 model_output : & Tensor ,
@@ -182,8 +188,15 @@ impl DPMSolverSinglestepScheduler {
182188 }
183189 }
184190
185- /// One step for the first-order DPM-Solver (equivalent to DDIM).
186- /// See https://arxiv.org/abs/2206.00927 for the detailed derivation.
191+ /// One step for the first-order DPM-Solver (equivalent to DDIM).
192+ /// See https://arxiv.org/abs/2206.00927 for the detailed derivation.
193+ ///
194+ /// # Arguments
195+ ///
196+ /// * `model_output` - direct output from learned diffusion model
197+ /// * `timestep` - current discrete timestep in the diffusion chain
198+ /// * `prev_timestep` - previous discrete timestep in the diffusion chain
199+ /// * `sample` - current instance of sample being created by diffusion process
187200 fn dpm_solver_first_order_update (
188201 & self ,
189202 model_output : & Tensor ,
@@ -205,7 +218,15 @@ impl DPMSolverSinglestepScheduler {
205218 }
206219 }
207220
208- /// One step for the second-order multistep DPM-Solver.
221+ /// One step for the second-order multistep DPM-Solver.
222+ /// It computes the solution at time `prev_timestep` from the time `timestep_list[-2]`.
223+ ///
224+ /// # Arguments
225+ ///
226+ /// * `model_output_list` - direct outputs from learned diffusion model at current and latter timesteps
227+ /// * `timestep_list` - current and latter discrete timestep in the diffusion chain
228+ /// * `prev_timestep` - previous discrete timestep in the diffusion chain
229+ /// * `sample` - current instance of sample being created by diffusion process
209230 fn singlestep_dpm_solver_second_order_update (
210231 & self ,
211232 model_output_list : & Vec < Tensor > ,
@@ -259,6 +280,14 @@ impl DPMSolverSinglestepScheduler {
259280 }
260281
261282 /// One step for the third-order multistep DPM-Solver
283+ /// It computes the solution at time `prev_timestep` from the time `timestep_list[-3]`.
284+ ///
285+ /// # Arguments
286+ ///
287+ /// * `model_output_list` - direct outputs from learned diffusion model at current and latter timesteps
288+ /// * `timestep_list` - current and latter discrete timestep in the diffusion chain
289+ /// * `prev_timestep` - previous discrete timestep in the diffusion chain
290+ /// * `sample` - current instance of sample being created by diffusion process
262291 fn singlestep_dpm_solver_third_order_update (
263292 & self ,
264293 model_output_list : & Vec < Tensor > ,
@@ -321,8 +350,15 @@ impl DPMSolverSinglestepScheduler {
321350 self . timesteps . as_slice ( )
322351 }
323352
353+ /// Step function propagating the sample with the singlestep DPM-Solver
354+ ///
355+ /// # Arguments
356+ ///
357+ /// * `model_output` - direct output from learned diffusion model
358+ /// * `timestep` - current discrete timestep in the diffusion chain
359+ /// * `sample` - current instance of sample being created by diffusion process
324360 pub fn step ( & mut self , model_output : & Tensor , timestep : usize , sample : & Tensor ) -> Tensor {
325- // https://github.com/huggingface/diffusers/blob/e4fe9413121b78c4c1f109b50f0f3cc1c320a1a2/src/diffusers/schedulers/scheduling_dpmsolver_multistep .py#L457
361+ // https://github.com/huggingface/diffusers/blob/e4fe9413121b78c4c1f109b50f0f3cc1c320a1a2/src/diffusers/schedulers/scheduling_dpmsolver_singlestep .py#L535
326362 let step_index: usize = self . timesteps . iter ( ) . position ( |& t| t == timestep) . unwrap ( ) ;
327363
328364 let prev_timestep =
@@ -384,8 +420,15 @@ impl DPMSolverSinglestepScheduler {
384420}
385421
386422/// Computes the solver order at each time step.
387- /// solver_order 1 2 3
388- fn get_order_list < ' a > ( steps : usize , solver_order : usize , lower_order_final : bool ) -> Vec < usize > {
423+ ///
424+ /// # Arguments
425+ ///
426+ /// * `steps` - the number of diffusion steps used when generating samples with a pre-trained model
427+ /// * `solver_order` - the order of DPM-Solver; can be `1` or `2` or `3`. We recommend to use `solver_order=2` for guided
428+ /// sampling, and `solver_order=3` for unconditional sampling.
429+ /// * `lower_order_final` - whether to use lower-order solvers in the final steps. For singlestep schedulers, we recommend to enable
430+ /// this to use up all the function evaluations.
431+ fn get_order_list ( steps : usize , solver_order : usize , lower_order_final : bool ) -> Vec < usize > {
389432 if lower_order_final {
390433 if solver_order == 3 {
391434 if steps % 3 == 0 {
0 commit comments