MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / LogProgress

Function LogProgress

oneflow/core/job/utils/progress_bar.cpp:24–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22namespace oneflow {
23
24Maybe<void> LogProgress(const std::string& task_name, bool is_end) {
25 const bool log_progress =
26 GetGraphDebugMode() || ThreadLocalEnvBool<ONEFLOW_NNGRAPH_ENABLE_PROGRESS_BAR>();
27 if (!log_progress || OF_PREDICT_FALSE(GlobalProcessCtx::Rank() != 0)) {
28 return Maybe<void>::Ok();
29 }
30
31 const static thread_local uint64_t progress_total_num = 60;
32 static thread_local uint64_t progress_cnt = 1;
33 static constexpr char clear_line[] =
34 " \r";
35
36 auto const& limited_str = task_name.size() > 60 ? task_name.substr(0, 60) : task_name;
37 std::cout << clear_line << "[" << progress_cnt << "/" << progress_total_num << "]" << limited_str
38 << "\r" << std::flush;
39 if (is_end) {
40 progress_cnt = 0;
41 std::cout << clear_line << std::endl << std::flush;
42 }
43 ++progress_cnt;
44 return Maybe<void>::Ok();
45}
46
47} // namespace oneflow

Callers 2

InitRuntimeMethod · 0.85
CountMethod · 0.85

Calls 2

GetGraphDebugModeFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected