Skip to content

Add lru_cache for node comparison #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions exir/backend/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

from functools import lru_cache
from typing import Iterable, List, Tuple

import torch
Expand All @@ -16,6 +17,7 @@
T_DQuantPerTensor = exir_ops.edge.quantized_decomposed.dequantize_per_tensor.default


@lru_cache(maxsize=128)
def is_same_node(
node_left: Iterable[torch.fx.Node],
node_right: Iterable[torch.fx.Node],
Expand All @@ -39,8 +41,6 @@ def is_same_node(
if len(list(node_left)) != len(list(node_right)):
return False
for n_left, n_right in zip(node_left, node_right):
# pyre-fixme[6]: For 1st argument expected `Iterable[Node]` but got `Node`.
# pyre-fixme[6]: For 2nd argument expected `Iterable[Node]` but got `Node`.
if not is_same_node(n_left, n_right):
return False
return True
Expand Down