| 64 | |
| 65 | |
| 66 | def 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 | |
| 84 | def remove_first_quant_and_last_dequant( |