| 434 | } |
| 435 | |
| 436 | void TFCode::Build() { |
| 437 | int64 unaccounted_nodes = 0; |
| 438 | for (auto it : grad_nodes_) { |
| 439 | const string& forward_name = it.first; |
| 440 | auto forward_it = forward_nodes_.find(forward_name); |
| 441 | if (forward_it == forward_nodes_.end()) { |
| 442 | unaccounted_nodes += 1; |
| 443 | continue; |
| 444 | } |
| 445 | TFGraphNode* fn = forward_it->second; |
| 446 | CodeNode* leaf = nullptr; |
| 447 | CodeNode* pre_code_node = root_.get(); |
| 448 | for (int i = 0; i < fn->call_stack()->traces().size(); ++i) { |
| 449 | const string& trace = |
| 450 | GetTraceString(fn->call_stack()->traces().at(i)) + kGradientSuffix; |
| 451 | pre_code_node = pre_code_node->AddChildren( |
| 452 | trace, &fn->call_stack()->traces().at(i), kGradientSuffix); |
| 453 | if (i == fn->call_stack()->traces().size() - 1) { |
| 454 | leaf = pre_code_node; |
| 455 | } |
| 456 | } |
| 457 | for (TFGraphNode* gn : it.second) { |
| 458 | leaf->node->AddGraphNode(gn); |
| 459 | } |
| 460 | } |
| 461 | if (unaccounted_nodes > 0) { |
| 462 | fprintf(stderr, "%lld gradient nodes not accounted\n", unaccounted_nodes); |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | const ShowMultiNode* TFCode::ShowInternal(const Options& opts, |
| 467 | Timeline* timeline) { |
nothing calls this directly
no test coverage detected