mirror of https://github.com/Nonannet/copapy.git
fix auto graph stripping
This commit is contained in:
parent
3c5f01db7f
commit
ce15e83c2b
|
|
@ -336,7 +336,7 @@ class CPConstant(Node):
|
|||
self.dtype, self.value = _get_data_and_dtype(value)
|
||||
self.name = 'const_' + self.dtype
|
||||
self.args = tuple()
|
||||
self.node_hash = hash(value) if constant else id(self)
|
||||
self.node_hash = hash(value) ^ hash(self.dtype) if constant else id(self)
|
||||
|
||||
|
||||
class Write(Node):
|
||||
|
|
|
|||
|
|
@ -102,14 +102,19 @@ def get_all_dag_edges(nodes: Iterable[Node]) -> Generator[tuple[Node, Node], Non
|
|||
Tuples of (source_node, target_node) representing edges in the DAG
|
||||
"""
|
||||
emitted_edges: set[tuple[Node, Node]] = set()
|
||||
used_nets: set[Net] = set()
|
||||
used_nets: dict[Net, Net] = {}
|
||||
node_list: list[Node] = [n for n in nodes]
|
||||
|
||||
while(node_list):
|
||||
node = node_list.pop()
|
||||
for net in node.args:
|
||||
if net not in used_nets:
|
||||
used_nets.add(net)
|
||||
|
||||
# In case there is already net with equivalent value use this
|
||||
if net in used_nets:
|
||||
net = used_nets[net]
|
||||
else:
|
||||
used_nets[net] = net
|
||||
|
||||
edge = (net.source, node)
|
||||
if edge not in emitted_edges:
|
||||
yield edge
|
||||
|
|
|
|||
Loading…
Reference in New Issue