Initializes mapping from tensor's name to ops that take it. Helps find edges between ops faster and avoids iterating over the whole graph. The mapping is of type Dict[str, Set[tf.Operation]]. Note: while inserting operations into the graph, we do not update the mapping, assuming
(self, graph)
| 26 | """Holds a mapping from tensor's name to ops that take it as input.""" |
| 27 | |
| 28 | def __init__(self, graph): |
| 29 | """Initializes mapping from tensor's name to ops that take it. |
| 30 | |
| 31 | Helps find edges between ops faster and avoids iterating over the whole |
| 32 | graph. The mapping is of type Dict[str, Set[tf.Operation]]. |
| 33 | |
| 34 | Note: while inserting operations into the graph, we do not update the |
| 35 | mapping, assuming that insertion points in the graph are never adjacent. |
| 36 | With that restriction, an out of date mapping still works fine. |
| 37 | |
| 38 | Args: |
| 39 | graph: Graph to process. |
| 40 | """ |
| 41 | self.mapping = collections.defaultdict(set) |
| 42 | for op in (op for op in graph.get_operations()): |
| 43 | if op.name.startswith(common.SKIPPED_PREFIXES): |
| 44 | continue |
| 45 | for op_input in op.inputs: |
| 46 | self.mapping[op_input].add(op) |
| 47 | |
| 48 | def ConsumerOperations(self, producer_op): |
| 49 | """Looks through outputs of producer_op, finds ops that take them as input. |
nothing calls this directly
no test coverage detected