(self, graph)
| 145 | |
| 146 | class 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 | |
| 168 | class Rename(): |
nothing calls this directly
no test coverage detected