Skip to content
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

Memoize result for the same node in evalNode() #21

Open
mitschabaude opened this issue Sep 27, 2024 · 0 comments
Open

Memoize result for the same node in evalNode() #21

mitschabaude opened this issue Sep 27, 2024 · 0 comments

Comments

@mitschabaude
Copy link
Member

Currently, if evalNode() would encounter the same node twice, it would perform all (in-circuit) computations that make up that node twice.

This could become a huge waste if we want to add expensive operations as possible nodes that should be used in several places.

There's an easy fix, we just have to add a store which contains the result of each previously evaluated node, and to reuse that when it already exists.

The only question is how to define "same" node. A first step is to just look for object identity and store intermediate results in a Map<Node, any>.

A more refined strategy would also recognize nodes that were defined multiple times but are equivalent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant