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

Method __init__

tools/low_precision_optimize/simple_graph.py:95–119  ·  view source on GitHub ↗
(self, graph_def: tf.GraphDef)

Source from the content-addressed store, hash-verified

93
94class SimpleGraph:
95 def __init__(self, graph_def: tf.GraphDef):
96 self._nodes = [
97 SimpleNode(name=n.name, op=n.op, inputs=list(n.input))
98 for n in graph_def.node
99 ]
100 self._name2index = {n.name: i for i, n in enumerate(graph_def.node)}
101 self._graph_def = graph_def
102
103 for node in graph_def.node:
104 for inp in node.input:
105 inp_node_name = tensor_name_to_node_name(inp)
106 inp_tensor_name = get_canonical_tensor_name(inp)
107 if inp_node_name not in self._name2index:
108 raise Exception(f"SimpleNode {node.name}: Unknown input node {inp}")
109 input_node = self._nodes[self._name2index[inp_node_name]]
110 # update input node"s [output_node, ..] list
111 input_node.output_nodes.append(node.name)
112 # update input node"s {tensor: output_node, ..} dictionary
113 # TODO: we are missing Graph final output node"s tensors,
114 # but it is not possible to inspect how many tensors inside
115 # it, therefore we currently ignore it.
116 if inp_tensor_name not in input_node.tensors:
117 input_node.tensors[inp_tensor_name] = [node.name]
118 else:
119 input_node.tensors[inp_tensor_name].append(node.name)
120
121 @property
122 def num_nodes(self) -> int:

Callers

nothing calls this directly

Calls 4

tensor_name_to_node_nameFunction · 0.85
SimpleNodeClass · 0.70
appendMethod · 0.45

Tested by

no test coverage detected