| 588 | } |
| 589 | |
| 590 | Status GraphConstructor::BuildNodeIndex() { |
| 591 | // Validate the node names and add them to gdef_nodes_ and gdef_prefixes_. |
| 592 | for (int n = 0; n < node_def_count(); ++n) { |
| 593 | const NodeDef& node_def = get_node_def(n); |
| 594 | if (!IsValidNodeName(node_def.name(), opts_.allow_internal_ops)) { |
| 595 | return errors::InvalidArgument( |
| 596 | "Node '", node_def.name(), |
| 597 | "': Node name contains invalid characters"); |
| 598 | } |
| 599 | if (!gdef_nodes_ |
| 600 | .insert(std::make_pair(StringPiece(node_def.name()), NodeInfo(n))) |
| 601 | .second) { |
| 602 | return errors::InvalidArgument("Node '", node_def.name(), |
| 603 | "' is not unique"); |
| 604 | } |
| 605 | // Validate the operation's type. |
| 606 | if (node_def.op().empty()) { |
| 607 | return errors::InvalidArgument("Node '", node_def.name(), |
| 608 | "' does not specify an operation"); |
| 609 | } |
| 610 | if (opts_.expect_device_spec && node_def.device().empty()) { |
| 611 | return errors::InvalidArgument("Node '", node_def.name(), |
| 612 | "' is missing a device specification"); |
| 613 | } |
| 614 | if (IsMerge(node_def)) { |
| 615 | merge_node_indices_.insert(n); |
| 616 | } |
| 617 | // Validate control edges at end |
| 618 | bool in_control_dependence = false; |
| 619 | for (int i = 0; i < node_def.input_size(); ++i) { |
| 620 | StringPiece input_name = node_def.input(i); |
| 621 | if (!input_name.empty() && absl::StartsWith(input_name, "^")) { |
| 622 | in_control_dependence = true; |
| 623 | } else if (in_control_dependence) { |
| 624 | return errors::InvalidArgument( |
| 625 | "Node '", node_def.name(), |
| 626 | "': Control dependencies must come after regular dependencies"); |
| 627 | } |
| 628 | } |
| 629 | // Update gdef_prefixes_. |
| 630 | AddPrefixes(node_def.name(), &gdef_prefixes_); |
| 631 | } |
| 632 | return Status::OK(); |
| 633 | } |
| 634 | |
| 635 | Status GraphConstructor::InitFromEdges() { |
| 636 | const int num_nodes = node_def_count(); |
nothing calls this directly
no test coverage detected