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

Simplifying rewrites for flatten/reshape #98

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

gussmith23
Copy link
Owner

The intention here was to add simplifying rewrites so that flatten/unflatten wouldn't run rampant. If we could add more equivalences (i.e. saying that stacking flattens is equivalent to just one flatten, or that flatten-then-reshape is equal to just reshape) then we can compress the egraph down. However, we haven't seemed to improve much:

Without rewrites:

Runner report
=============
  Stop reason: TimeLimit(60.958206912)
  Iterations: 41
  Egraph size: 278240 nodes, 262325 classes, 278269 memo
  Rebuilds: 10977, 267.73 per iter
  Total time: 60.27503701900001
    Search:  (0.09) 5.527444559
    Apply:   (0.15) 8.843468115999999
    Rebuild: (0.76) 45.904067723999994

With rewrites:

Runner report
=============
  Stop reason: TimeLimit(61.440639892)
  Iterations: 40
  Egraph size: 280628 nodes, 260861 classes, 280782 memo
  Rebuilds: 14521, 363.02 per iter
  Total time: 60.788746081999996
    Search:  (0.09) 5.595972895000001
    Apply:   (0.14) 8.638404146000001

It seems like the number of classes goes down somewhat, but overall performance degrades (we run fewer iterations, have more rebuilding). I'm not quite sure how to interpret this -- is it just that these rewrites aren't actually useful, and are just hurting us?

@gussmith23
Copy link
Owner Author

I think I have the right intention (trying to shrink the number of classes by adding simplifying rewrites) but perhaps I'm not focusing on the right target. The thing that (probably) blows things up the most is the slice/concat rewrite, so we should target that.

@gussmith23 gussmith23 added on hold Issues that are temporarily or indefinitely not being worked on rewrites Improve Glenside's egraph rewrites labels Dec 17, 2020
@gussmith23
Copy link
Owner Author

I'm not going to merge this for now, as it doesn't seem to be doing anything good. I should take a look at this again after I try simplifying concatenates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on hold Issues that are temporarily or indefinitely not being worked on rewrites Improve Glenside's egraph rewrites
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant