@@ -357,6 +357,39 @@ void pretty_progress(int step, int steps, float time) {
357357 }
358358}
359359
360+ #ifdef SD_SHOW_REMAINING_TIME
361+ void pretty_progress (int step, int steps, float time, float left) {
362+ if (sd_progress_cb) {
363+ sd_progress_cb (step, steps, time, sd_progress_cb_data);
364+ return ;
365+ }
366+ if (step == 0 ) {
367+ return ;
368+ }
369+ std::string progress = " |" ;
370+ int max_progress = 50 ;
371+ int32_t current = (int32_t )(step * 1 .f * max_progress / steps);
372+ for (int i = 0 ; i < 50 ; i++) {
373+ if (i > current) {
374+ progress += " " ;
375+ } else if (i == current && i != max_progress - 1 ) {
376+ progress += " >" ;
377+ } else {
378+ progress += " =" ;
379+ }
380+ }
381+ progress += " |" ;
382+ printf (time > 1 .0f ? " \r %s %i/%i - %.2fs/it" : " \r %s %i/%i - %.2fit/s\033 [K" ,
383+ progress.c_str (), step, steps,
384+ time > 1 .0f || time == 0 ? time : (1 .0f / time));
385+ printf (" , %.0fm %.2fs left " , left / 60 , fmod (left, 60 ));
386+ fflush (stdout); // for linux
387+ if (step == steps) {
388+ printf (" \n " );
389+ }
390+ }
391+ #endif // SD_SHOW_REMAINING_TIME
392+
360393std::string ltrim (const std::string& s) {
361394 auto it = std::find_if (s.begin (), s.end (), [](int ch) {
362395 return !std::isspace (ch);
@@ -686,4 +719,4 @@ std::vector<std::pair<std::string, float>> parse_prompt_attention(const std::str
686719 }
687720
688721 return res;
689- }
722+ }
0 commit comments