MCPcopy Create free account
hub / github.com/pytorch/executorch / is_identical_graph

Function is_identical_graph

exir/backend/utils.py:66–81  ·  view source on GitHub ↗
(
    graph_left: torch.fx.GraphModule, graph_right: torch.fx.GraphModule
)

Source from the content-addressed store, hash-verified

64
65
66def is_identical_graph(
67 graph_left: torch.fx.GraphModule, graph_right: torch.fx.GraphModule
68) -> bool:
69 # two graph are the same if they have the same nodes and op. The order of nodes also
70 # matters in this function is more strict. Two graph are not considered as the same
71 # if the topological order of the nodes is the same in this function but the order of nodes
72 # is not the same.
73 if len(list(graph_left.graph.nodes)) != len(list(graph_right.graph.nodes)):
74 return False
75 with setting_python_recursive_limit(30000):
76 for node_left, node_right in zip(
77 graph_left.graph.nodes, graph_right.graph.nodes
78 ):
79 if not (is_same_node(node_left, node_right)):
80 return False
81 return True
82
83
84def remove_first_quant_and_last_dequant(

Calls 2

is_same_nodeFunction · 0.85