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

Optimize static switches #2477

Merged
merged 2 commits into from
Jan 19, 2024
Merged

Conversation

RunDevelopment
Copy link
Member

Fixes #2262.

This adds a backend compiler optimization that statically executes (kinda) the Switch node if the selected input is statically known (it currently always is). Static execution is a strong word. In actuality, it just removes the edges from inputs that aren't selected. However, the effect is the same: only the selected input will be executed.

Of course, this new optimization works together with the already present removed_dead_nodes optimization.

Other changes:

  • To implement this optimization, I also had to make some (long overdue) changes to the Chain. It now contains node input values instead of just edges. Since optimization may add, change, and remove nodes, they also need to be able to influence input values.
  • Optimization now use mutation signal instead of returning a bool to say that they changed the chain. This just makes optimizations a little easier to implement.
  • Use data classes in a few places.
  • The executor now derives the input map it used from the given chain.

@joeyballentine joeyballentine merged commit 6074c56 into chaiNNer-org:main Jan 19, 2024
14 checks passed
@RunDevelopment RunDevelopment deleted the issue2262 branch January 19, 2024 21:30
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

Successfully merging this pull request may close these issues.

Compiler optimization: "Execute" Switch node statically
2 participants