Skip to content

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

Description

@mitschabaude

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions