MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / __init__

Method __init__

tensorflow/contrib/quantize/python/input_to_ops.py:28–46  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 2

get_operationsMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected