Skip to content

Commit

Permalink
add README
Browse files Browse the repository at this point in the history
  • Loading branch information
bollu committed Dec 13, 2021
1 parent 582ee2e commit 2caf4b2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# MLIR, Hoopl, Rete

That's a very confused title. What's this repo about?
- MLIR needs the ability to perform fast pattern matching and rewrites on the IR.
- [rete](https://en.wikipedia.org/wiki/Rete_algorithm) is an ancient algorithm from the time of Old AI to pattern match
and rewrite databases of 'facts'.
- [Hoopl](https://github.com/haskell/hoopl) is a technique (originally developed for the Haskell compiler, GHC) to interleave
dataflow analysis and rewrites on a nested CFG.
- It appears that there's an opportunity here. Shove MLIR (which is a CFG, nested by regions) into a Rete network, and add
pattern matchers and rewrites to "mine facts" from the IR. That this is safe to do is proven in the [Hoopl paper](https://www.microsoft.com/en-us/research/wp-content/uploads/2016/07/hoopl-haskell10.pdf).
- If this works, we get a clean, decades old algorithm to implement MLIR *analyses and rewrites* .
- Only problem: I implemented the naive `rete` algorithm. [the benchmarks aren't so hot](https://github.com/bollu/mlir-hoopl-rete/pull/2).
- I have ideas on how to improve the performance (use hashing within the rete `join` nodes, don't pay `O(n^2)` cost to match uses with defs).
But this needs more time. I'll probably grab some time during a retreat `:)`.

0 comments on commit 2caf4b2

Please sign in to comment.