Add lru_cache for node comparison (#148)
Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/148 cache the args to optimize the number of calls. For `is_same_node` function, we're expecting the same results each time it's called with the same inputs. For mv2, ``` buck run mode/dev-nosan //executorch/examples/backend:xnnpack_examples -- -m mv2 -q -d ``` The total number of nodes in mv2 graph after quantize is 520. Before the change: mv2: The number of call to `is_same_node` is 6388036 🙈 mv2: to_backend call time: 30.79 second (including dumping the logs) mv3: takes forever After the change: mv2: The number of call to `is_same_node` is 520. It's more reasonable mv2: to_backend call time: 10.15 second (including dumping the logs) mv3: `to_backend` call takes 16 second. Reviewed By: digantdesai, mcr229 Differential Revision: D48708658 fbshipit-source-id: 8585c417d6d7c27bbacda563c0a7a7a764f0674e
C
Chen Lai committed
7299bf3daffd0bc853d4fff608b99545b7748cf7
Parent: 9ede813
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
on 8/26/2023, 4:21:03 AM