Trace inputs. Args: graph_element_name: Name of the node or an output tensor of the node, as a str. Raises: GraphTracingReachedDestination: if destination_node_name of this tracer object is not None and the specified node is reached.
(self, graph_element_name)
| 178 | self._destination_node_name = destination_node_name |
| 179 | |
| 180 | def trace(self, graph_element_name): |
| 181 | """Trace inputs. |
| 182 | |
| 183 | Args: |
| 184 | graph_element_name: Name of the node or an output tensor of the node, as a |
| 185 | str. |
| 186 | |
| 187 | Raises: |
| 188 | GraphTracingReachedDestination: if destination_node_name of this tracer |
| 189 | object is not None and the specified node is reached. |
| 190 | """ |
| 191 | self._depth_count += 1 |
| 192 | |
| 193 | node_name = get_node_name(graph_element_name) |
| 194 | if node_name == self._destination_node_name: |
| 195 | raise GraphTracingReachedDestination() |
| 196 | |
| 197 | if node_name in self._skip_node_names: |
| 198 | return |
| 199 | if node_name in self._visited_nodes: |
| 200 | return |
| 201 | |
| 202 | self._visited_nodes.append(node_name) |
| 203 | |
| 204 | for input_list in self._input_lists: |
| 205 | if node_name not in input_list: |
| 206 | continue |
| 207 | for inp in input_list[node_name]: |
| 208 | if get_node_name(inp) in self._visited_nodes: |
| 209 | continue |
| 210 | self._inputs.append(inp) |
| 211 | self._depth_list.append(self._depth_count) |
| 212 | self.trace(inp) |
| 213 | |
| 214 | self._depth_count -= 1 |
| 215 | |
| 216 | def inputs(self): |
| 217 | return self._inputs |