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

Conversation

cccclai
Copy link
Contributor

@cccclai cccclai commented Aug 26, 2023

Summary:
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

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 26, 2023
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D48708658

Summary:
Pull Request resolved: pytorch/executorch#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: ce2b7f5835ed17fa6df75a3bfcee495b2ab0a4a2
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D48708658

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 7299bf3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants