Multi-Pattern Example
jafioti opened this issue · 1 comments
jafioti commented
Are there any examples of using multi-pattern rewrites? I couldn't find any, but the paper claims this is possible
yihozhang commented
Take the multi-pattern rewrite rule in Figure 2 of this paper for example. It can be expressed in egglog as
(datatype Expr
(matmul Expr Expr)
(split0 Expr)
(split1 Expr)
(split i64 Expr)
(concat i64 Expr Expr))
(rule (
(= e1 (matmul i1 i2))
(= e2 (matmul i1 i3))
(!= i2 i3)
) (
(let fused (matmul i1 (concat 1 i2 i3)))
(let new-e1 (split0 (split 1 fused)))
(let new-e2 (split1 (split 1 fused)))
(union new-e1 e1)
(union new-e2 e2)
))