| 45 | // It will only appear as cpu:0. |
| 46 | |
| 47 | void ExecStep::AddTimeStats(const string& dev, const NodeExecStats& step_stat) { |
| 48 | devices_.insert(dev); |
| 49 | if (step_stat.all_start_micros() > 0) { |
| 50 | if (exec_.all_start_micros() > 0) { |
| 51 | exec_.set_all_start_micros( |
| 52 | std::min(static_cast<int64>(exec_.all_start_micros()), |
| 53 | static_cast<int64>(step_stat.all_start_micros()))); |
| 54 | } else { |
| 55 | exec_.set_all_start_micros(step_stat.all_start_micros()); |
| 56 | } |
| 57 | int64 op_end_rel_micros = step_stat.op_end_rel_micros(); |
| 58 | // Round quick execution to 1 micro to be semantically robust. |
| 59 | if (op_end_rel_micros == 0) { |
| 60 | ++op_end_rel_micros; |
| 61 | } |
| 62 | exec_.set_latest_end_micros( |
| 63 | std::max(static_cast<int64>(exec_.latest_end_micros()), |
| 64 | step_stat.all_start_micros() + op_end_rel_micros)); |
| 65 | |
| 66 | const std::pair<int64, int64> pair = |
| 67 | std::make_pair(step_stat.all_start_micros(), op_end_rel_micros); |
| 68 | if (CountAsAcceleratorTime(dev)) { |
| 69 | accelerator_execs_[dev].push_back(pair); |
| 70 | op_execs_[dev].push_back(pair); |
| 71 | } else if (CountAsCPUTime(dev)) { |
| 72 | cpu_execs_[dev].push_back(pair); |
| 73 | op_execs_[dev].push_back(pair); |
| 74 | // In while-loop, a graph node is executed multiple times under |
| 75 | // the same name. |
| 76 | exec_.set_run_count(exec_.run_count() + 1); |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | void ExecStep::AddMemoryStats(const string& dev, |
| 82 | const NodeExecStats& step_stat) { |
no test coverage detected