| 227 | } |
| 228 | |
| 229 | void FromProto(const ExecProfile& exec) { |
| 230 | exec_.Clear(); |
| 231 | exec_.MergeFrom(exec); |
| 232 | |
| 233 | devices_.clear(); |
| 234 | devices_.insert(exec.devices().begin(), exec.devices().end()); |
| 235 | |
| 236 | accelerator_execs_.clear(); |
| 237 | cpu_execs_.clear(); |
| 238 | op_execs_.clear(); |
| 239 | |
| 240 | allocations_.clear(); |
| 241 | memory_execs_.clear(); |
| 242 | |
| 243 | for (const auto& exec_time : exec_.accelerator_execs()) { |
| 244 | auto& exec = accelerator_execs_[exec_time.first]; |
| 245 | auto& op_exec = op_execs_[exec_time.first]; |
| 246 | for (const auto& p : exec_time.second.times()) { |
| 247 | exec.push_back(std::make_pair(p.int64_values(0), p.int64_values(1))); |
| 248 | op_exec.push_back(std::make_pair(p.int64_values(0), p.int64_values(1))); |
| 249 | } |
| 250 | } |
| 251 | for (const auto& exec_time : exec_.cpu_execs()) { |
| 252 | auto& exec = cpu_execs_[exec_time.first]; |
| 253 | auto& op_exec = op_execs_[exec_time.first]; |
| 254 | for (const auto& p : exec_time.second.times()) { |
| 255 | exec.push_back(std::make_pair(p.int64_values(0), p.int64_values(1))); |
| 256 | op_exec.push_back(std::make_pair(p.int64_values(0), p.int64_values(1))); |
| 257 | } |
| 258 | } |
| 259 | for (const auto& r : exec_.allocations()) { |
| 260 | allocations_.push_back(r); |
| 261 | } |
| 262 | for (const auto& m : exec_.memory_execs()) { |
| 263 | memory_execs_.push_back(m); |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | private: |
| 268 | ExecProfile exec_; |