| 262 | } |
| 263 | |
| 264 | void TFStats::AddRunMeta(int64 step, std::unique_ptr<RunMetadata> run_meta) { |
| 265 | if (!run_meta || !run_meta->has_step_stats()) { |
| 266 | fprintf(stderr, "Invalid RunMetadata for step %lld\n", step); |
| 267 | return; |
| 268 | } |
| 269 | if (steps_.find(step) == steps_.end()) { |
| 270 | steps_.insert(step); |
| 271 | } |
| 272 | steps_.insert(step); |
| 273 | |
| 274 | bool has_gpu_scheduling = false; |
| 275 | bool has_gpu_stream = false; |
| 276 | |
| 277 | for (const auto& dev_stat : run_meta->step_stats().dev_stats()) { |
| 278 | string dev = absl::AsciiStrToLower(dev_stat.device()); |
| 279 | if (IsPlacedOnAccelerator(dev)) { |
| 280 | has_gpu_scheduling = true; |
| 281 | if (CountAsAcceleratorTime(dev)) { |
| 282 | has_gpu_stream = true; |
| 283 | } |
| 284 | } |
| 285 | for (const NodeExecStats& node_stat : dev_stat.node_stats()) { |
| 286 | string name = node_stat.node_name(); |
| 287 | // Sometimes the node_name is suffixed with unnecessary information. |
| 288 | auto split_pos = node_stat.node_name().find(":"); |
| 289 | if (split_pos != node_stat.node_name().npos) { |
| 290 | name = node_stat.node_name().substr(0, split_pos); |
| 291 | } |
| 292 | auto node = nodes_map_.find(name); |
| 293 | if (node == nodes_map_.end()) { |
| 294 | NodeDef def; |
| 295 | if (CreateRunMetadataNode(name, &def)) { |
| 296 | size_t num_nodes = nodes_map_.size(); |
| 297 | nodes_map_[name] = std::unique_ptr<TFGraphNode>( |
| 298 | new TFGraphNode(&def, num_nodes, &nodes_map_)); |
| 299 | nodes_map_.at(name)->AddStepStat(step, dev_stat.device(), node_stat); |
| 300 | } |
| 301 | } else { |
| 302 | covered_nodes_.insert(node->second->id()); |
| 303 | node->second->AddStepStat(step, dev_stat.device(), node_stat); |
| 304 | } |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | if (has_gpu_scheduling && !has_gpu_stream) { |
| 309 | miss_accelerator_stream_ = true; |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | string TFStats::MaybeReportMissingTrace() const { |
| 314 | string report = ""; |
no test coverage detected