Gets all the edges in the immediate fanin of a node. Include the controlling edges iff include_controlling_edges is true.
| 297 | // Gets all the edges in the immediate fanin of a node. Include the |
| 298 | // controlling edges iff include_controlling_edges is true. |
| 299 | absl::flat_hash_set<Edge> GetFaninEdges( |
| 300 | const NodeDefT& node, bool include_controlling_edges) const { |
| 301 | absl::flat_hash_set<Edge> result; |
| 302 | const int max_input_port = |
| 303 | include_controlling_edges |
| 304 | ? node.input_size() - 1 |
| 305 | : gtl::FindWithDefault(max_regular_input_port_, &node, -1); |
| 306 | for (int i = 0; i <= max_input_port; ++i) { |
| 307 | TensorId tensor_id = ParseTensorName(node.input(i)); |
| 308 | |
| 309 | auto it = nodes_.find(tensor_id.node()); |
| 310 | if (it != nodes_.end()) { |
| 311 | result.emplace(/*src=*/OutputPort(it->second, tensor_id.index()), |
| 312 | /*dst=*/InputPort(const_cast<NodeDefT*>(&node), i)); |
| 313 | } |
| 314 | } |
| 315 | return result; |
| 316 | } |
| 317 | |
| 318 | protected: |
| 319 | explicit GraphViewInternal(GraphDefT* graph) : graph_(graph) {} |