File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
src/kirin/dialects/vmath/rewrites Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 44from kirin .rewrite .abc import RewriteRule , RewriteResult
55from kirin .ir .nodes .base import IRNode
66from kirin .dialects .ilist import IListType
7- from kirin .dialects .ilist .runtime import IList
87
98from ..stmts import add as vadd , div as vdiv , mul as vmul , sub as vsub
109from .._dialect import dialect
1110
1211
1312class DesugarBinOp (RewriteRule ):
13+ """
14+ Convert py.BinOp statements with one scalar arg and one IList arg
15+ to the corresponding vmath binop. Currently supported binops are
16+ add, mult, sub, and div. BinOps where both args are IList are not
17+ supported, since `+` between two IList objects is taken to mean
18+ concatenation.
19+ """
1420
1521 def rewrite_Statement (self , node : ir .Statement ) -> RewriteResult :
1622 match node :
@@ -49,6 +55,10 @@ def replace_binop(self, node: ir.Statement) -> RewriteResult:
4955
5056@dialect .post_inference
5157class WalkDesugarBinop (RewriteRule ):
58+ """
59+ Walks DesugarBinop. Needed for correct behavior when
60+ registering as a post-inference rewrite.
61+ """
5262
5363 def rewrite (self , node : IRNode ):
5464 return Walk (DesugarBinOp ()).rewrite (node )
You can’t perform that action at this time.
0 commit comments