Flexible Matching via Equality Saturation
- Having patterns defined in Relay
- Run EqSat on each pattern and get the corresponding EGraph
- Pattern match on a given model using
EGraphMatcher
- Annotate matched region with BYOC-style function annotations for the codegen
Note: Please run cargo build
in the flexmatch
directory before using the utilities there.
flexmatch
: Rust interfaces that call glenside and apis in (my fork of) eggtests/run_eqsat
- Takes a relay source file, an output file name and config(s) (under
configs/
) - Run equality saturation on the given model with respect to rewrite rules in configs
- Example:
python3 run_eqsat.py models/resmlp.relay resmlp im2col-rewrites linear-rewrites
- Takes a relay source file, an output file name and config(s) (under
tests/compile_model
- Takes the relay source file, the output model and eclass analysis data json from EqSat
- Compiles the rewritten model back to a relay executable model and saves to a file
- Optional argument:
--debug
; instead of inserting accelerator calls, if this argument is passed, the equivalent relay function will be generated - Example:
python3 compile_model.py models/resmlp.relay resmlp-rewritten.relay resmlp-rewritten.json resmlp-data.json linear-rewrites im2col-rewrites --debug