| 28 | GenNode::GenNode(const NodeDef* node) : node_(node), op_(nullptr) {} |
| 29 | |
| 30 | Status GenNode::BuildGraphInMap(const GraphDef& source, GenNodeMap* map) { |
| 31 | for (const auto& n : source.node()) { |
| 32 | const string& name = n.name(); |
| 33 | if (map->find(name) != map->end()) { |
| 34 | // This error code looks more meaningful than ALREADY_EXISTS. |
| 35 | return Status(error::INVALID_ARGUMENT, |
| 36 | "Duplicate node name '" + name + "'."); |
| 37 | } |
| 38 | (*map)[name] = absl::make_unique<GenNode>(&n); |
| 39 | } |
| 40 | // Now parse the links. |
| 41 | for (const auto& mapit : *map) { |
| 42 | Status st = mapit.second->ParseInputs(map); |
| 43 | if (!st.ok()) { |
| 44 | return st; |
| 45 | } |
| 46 | } |
| 47 | return Status::OK(); |
| 48 | } |
| 49 | |
| 50 | Status GenNode::ParseInputs(const GenNodeMap* map) { |
| 51 | all_inputs_or_none_ = false; |