gussmith23 / glenside

A pure, low-level tensor program representation enabling tensor program optimization via program rewriting. See the web demo at https://gussmith23.github.io/glenside-web-demo/
71 stars 10 forks source link

Import Relay into Egraph using a Relay egg::Language; use rewrites to convert to glenside::language::Language #68

Open gussmith23 opened 4 years ago

gussmith23 commented 4 years ago

This issue has two parts:

  1. The creation of a Relay egg::Language (and, I'd bet, an associated egg::Analysis to hold the Relay op attributes) plus an importer that converts from Relay to an Egraph.
    • This actually has nothing to do with Glenside, and could exist as its own crate, or be contributed to TVM or egg.
    • This was originally @jroesch and/or @mwillsey's idea, I'm sure they could contribute more thoughts.
    • There was an idea that this could largely be done automatically with Rust macros.
  2. Converting Glenside's Relay->Glenside compiler to a system of rewrites.
    • If the Relay nodes are already in the egraph, then converting them to Glenside nodes is just a matter of having the right set of rewrites.
    • The interesting part here is that the Relay egraph and the Glenside egraph will have different egg::Analyses. I think that, at its core, the idea of multiple analyses is not a problem for an egraph, but I'm not sure it's currently supported by egg. There may be a clever way to implement overlapping analyses using Rust traits---i.e. Relay would provide one trait for its analysis, Glenside would provide another trait for its analysis, and an analysis could implement both of them. @mwillsey let me know what you think about this!

cc @hypercubestart!