MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / ggml_opt_epoch_callback_progress_bar

Function ggml_opt_epoch_callback_progress_bar

external/ggml/src/ggml-opt.cpp:926–997  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

924}
925
926void ggml_opt_epoch_callback_progress_bar(
927 bool train,
928 ggml_opt_context_t opt_ctx,
929 ggml_opt_dataset_t dataset,
930 ggml_opt_result_t result,
931 int64_t ibatch,
932 int64_t ibatch_max,
933 int64_t t_start_us) {
934 fprintf(stderr, "%s[", train ? "train: " : "val: ");
935
936 // The progress bar consists of partially filled blocks, unicode has 8 separate fill levels.
937 constexpr int64_t bar_length = 8;
938 const int64_t ibatch8 = 8 * ibatch;
939 for (int64_t j = 0; j < bar_length; ++j) {
940 if (ibatch_max * (8*j + 8) / bar_length < ibatch8) {
941 fprintf(stderr, "\u2588"); // full block
942 } else if (ibatch_max * (8*j + 7) / bar_length < ibatch8) {
943 fprintf(stderr, "\u2589"); // 7/8 filled
944 } else if (ibatch_max * (8*j + 6) / bar_length < ibatch8) {
945 fprintf(stderr, "\u258A"); // 6/8 filled
946 } else if (ibatch_max * (8*j + 5) / bar_length < ibatch8) {
947 fprintf(stderr, "\u258B"); // 5/8 filled
948 } else if (ibatch_max * (8*j + 4) / bar_length < ibatch8) {
949 fprintf(stderr, "\u258C"); // 4/8 filled
950 } else if (ibatch_max * (8*j + 3) / bar_length < ibatch8) {
951 fprintf(stderr, "\u258D"); // 3/8 filled
952 } else if (ibatch_max * (8*j + 2) / bar_length < ibatch8) {
953 fprintf(stderr, "\u258E"); // 2/8 filled
954 } else if (ibatch_max * (8*j + 1) / bar_length < ibatch8) {
955 fprintf(stderr, "\u258F"); // 1/8 filled
956 } else {
957 fprintf(stderr, " ");
958 }
959 }
960
961 const int64_t batch_size = ggml_opt_inputs(opt_ctx)->ne[1];
962 const int64_t idata = ibatch*batch_size;
963 const int64_t idata_max = ibatch_max*batch_size;
964
965 double loss;
966 double loss_unc;
967 ggml_opt_result_loss(result, &loss, &loss_unc);
968
969 double accuracy;
970 double accuracy_unc;
971 ggml_opt_result_accuracy(result, &accuracy, &accuracy_unc);
972
973 const int64_t t_ibatch_us = ggml_time_us() - t_start_us;
974 int64_t t_ibatch_s = t_ibatch_us / 1000000;
975 const int64_t t_ibatch_h = t_ibatch_s / 3600;
976 t_ibatch_s -= t_ibatch_h * 3600;
977 const int64_t t_ibatch_m = t_ibatch_s / 60;
978 t_ibatch_s -= t_ibatch_m * 60;
979
980 const int64_t t_eta_us = t_ibatch_us * (ibatch_max - ibatch)/ibatch;
981 int64_t t_eta_s = t_eta_us / 1000000;
982 const int64_t t_eta_h = t_eta_s / 3600;
983 t_eta_s -= t_eta_h * 3600;

Callers

nothing calls this directly

Calls 4

ggml_opt_inputsFunction · 0.85
ggml_opt_result_lossFunction · 0.85
ggml_opt_result_accuracyFunction · 0.85
ggml_time_usFunction · 0.85

Tested by

no test coverage detected