MCPcopy Index your code
hub / github.com/waleedka/hiddenlayer / apply

Method apply

hiddenlayer/transforms.py:147–165  ·  view source on GitHub ↗
(self, graph)

Source from the content-addressed store, hash-verified

145
146class FoldDuplicates():
147 def apply(self, graph):
148 # Copy the graph. Don't change the original.
149 graph = copy.deepcopy(graph)
150
151 matches = True
152 while matches:
153 for node in graph.nodes.values():
154 pattern = ge.SerialPattern([ge.NodePattern(node.op), ge.NodePattern(node.op)])
155 matches, _ = pattern.match(graph, node)
156 if matches:
157 combo = Node(uid=graph.sequence_id(matches),
158 name=node.name,
159 op=node.op,
160 output_shape=node.output_shape)
161 combo._caption = node.caption
162 combo.repeat = sum([n.repeat for n in matches])
163 graph.replace(matches, combo)
164 break
165 return graph
166
167
168class Rename():

Callers

nothing calls this directly

Calls 4

matchMethod · 0.95
NodeClass · 0.85
sequence_idMethod · 0.80
replaceMethod · 0.80

Tested by

no test coverage detected