| 85 | }; |
| 86 | |
| 87 | class ExecStep { |
| 88 | public: |
| 89 | ExecStep() {} |
| 90 | |
| 91 | void AddTimeStats(const string& dev, const NodeExecStats& step_stat); |
| 92 | |
| 93 | void AddMemoryStats(const string& dev, const NodeExecStats& step_stat); |
| 94 | |
| 95 | int64 run_count() const { return exec_.run_count(); } |
| 96 | // The execution time of an op. If it runs on accelerator, then it's |
| 97 | // accelerator_exec_micros(). Otherwise, it's CPU time. |
| 98 | int64 exec_micros() const; |
| 99 | // The accelerator execution time of an op. 0 if not run on accelerator. |
| 100 | int64 accelerator_exec_micros() const; |
| 101 | // The cpu execution time of an op. |
| 102 | int64 cpu_exec_micros() const; |
| 103 | |
| 104 | const std::map<string, std::vector<std::pair<int64, int64>>>& op_execs() |
| 105 | const { |
| 106 | return op_execs_; |
| 107 | } |
| 108 | const std::map<string, std::vector<std::pair<int64, int64>>>& cpu_execs() |
| 109 | const { |
| 110 | return cpu_execs_; |
| 111 | } |
| 112 | int64 all_start_micros() const { return exec_.all_start_micros(); } |
| 113 | int64 latest_end_micros() const { return exec_.latest_end_micros(); } |
| 114 | int64 lastest_schedule_end_micros() const { |
| 115 | int64 ret = 0; |
| 116 | for (const auto& exec : cpu_execs_) { |
| 117 | for (const auto& pair : exec.second) { |
| 118 | ret = std::max(ret, pair.first + pair.second); |
| 119 | } |
| 120 | } |
| 121 | return ret; |
| 122 | } |
| 123 | int64 requested_bytes() const { |
| 124 | int64 requested_bytes = 0; |
| 125 | for (const ExecMemory& exec : memory_execs_) { |
| 126 | requested_bytes += exec.requested_bytes(); |
| 127 | } |
| 128 | return requested_bytes; |
| 129 | } |
| 130 | int64 peak_bytes() const { |
| 131 | int64 peak_bytes = 0; |
| 132 | for (const ExecMemory& exec : memory_execs_) { |
| 133 | peak_bytes += exec.peak_bytes(); |
| 134 | } |
| 135 | return peak_bytes; |
| 136 | } |
| 137 | int64 residual_bytes() const { |
| 138 | int64 residual_bytes = 0; |
| 139 | for (const ExecMemory& exec : memory_execs_) { |
| 140 | residual_bytes += exec.residual_bytes(); |
| 141 | } |
| 142 | return residual_bytes; |
| 143 | } |
| 144 | int64 output_bytes() const { |