Skip to content

Commit d75d902

Browse files
more compact progress bar
1 parent 382ec20 commit d75d902

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

ggml/src/ggml-opt.cpp

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -864,13 +864,26 @@ void ggml_opt_epoch_callback_progress_bar(
864864
int64_t t_start_us) {
865865
fprintf(stderr, "%s[", train ? "train: " : "val: ");
866866

867-
constexpr int64_t bar_length = 25;
867+
// The progress bar consists of partially filled blocks, unicode has 8 separate fill levels.
868+
constexpr int64_t bar_length = 8;
869+
const int64_t ibatch8 = 8 * ibatch;
868870
for (int64_t j = 0; j < bar_length; ++j) {
869-
const int64_t ibatch_j = ibatch_max * j/bar_length;
870-
if (ibatch_j < ibatch) {
871-
fprintf(stderr, "=");
872-
} else if (ibatch_max * (j - 1)/bar_length < ibatch) {
873-
fprintf(stderr, ">");
871+
if (ibatch_max * (8*j + 8) / bar_length < ibatch8) {
872+
fprintf(stderr, "\u2588"); // full block
873+
} else if (ibatch_max * (8*j + 7) / bar_length < ibatch8) {
874+
fprintf(stderr, "\u2589"); // 7/8 filled
875+
} else if (ibatch_max * (8*j + 6) / bar_length < ibatch8) {
876+
fprintf(stderr, "\u258A"); // 6/8 filled
877+
} else if (ibatch_max * (8*j + 5) / bar_length < ibatch8) {
878+
fprintf(stderr, "\u258B"); // 5/8 filled
879+
} else if (ibatch_max * (8*j + 4) / bar_length < ibatch8) {
880+
fprintf(stderr, "\u258C"); // 4/8 filled
881+
} else if (ibatch_max * (8*j + 3) / bar_length < ibatch8) {
882+
fprintf(stderr, "\u258D"); // 3/8 filled
883+
} else if (ibatch_max * (8*j + 2) / bar_length < ibatch8) {
884+
fprintf(stderr, "\u258E"); // 2/8 filled
885+
} else if (ibatch_max * (8*j + 1) / bar_length < ibatch8) {
886+
fprintf(stderr, "\u258F"); // 1/8 filled
874887
} else {
875888
fprintf(stderr, " ");
876889
}
@@ -902,8 +915,8 @@ void ggml_opt_epoch_callback_progress_bar(
902915
const int64_t t_eta_m = t_eta_s / 60;
903916
t_eta_s -= t_eta_m * 60;
904917

905-
fprintf(stderr, "| data=%06" PRId64 "/%06" PRId64 ", loss=%.6lf+-%.6lf, accuracy=%.2lf+-%.2lf%%, "
906-
"t=%02" PRId64 ":%02" PRId64 ":%02" PRId64 ", ETA=%02" PRId64 ":%02" PRId64 ":%02" PRId64 "]\r",
918+
fprintf(stderr, "] data=%07" PRId64 "/%07" PRId64 " loss=%.5lf±%.5lf acc=%.2lf±%.2lf%% "
919+
"t=%02" PRId64 ":%02" PRId64 ":%02" PRId64 " ETA=%02" PRId64 ":%02" PRId64 ":%02" PRId64 " \r",
907920
idata, idata_max, loss, loss_unc, 100.0*accuracy, 100.0*accuracy_unc,
908921
t_ibatch_h, t_ibatch_m, t_ibatch_s, t_eta_h, t_eta_m, t_eta_s);
909922
if (ibatch == ibatch_max) {

0 commit comments

Comments
 (0)