Skip to content

Commit 87afeb8

Browse files
committed
add some docs
1 parent 3fb1f27 commit 87afeb8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/kirin/dialects/vmath/rewrites/desugar.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@
44
from kirin.rewrite.abc import RewriteRule, RewriteResult
55
from kirin.ir.nodes.base import IRNode
66
from kirin.dialects.ilist import IListType
7-
from kirin.dialects.ilist.runtime import IList
87

98
from ..stmts import add as vadd, div as vdiv, mul as vmul, sub as vsub
109
from .._dialect import dialect
1110

1211

1312
class 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
5157
class 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)

0 commit comments

Comments
 (0)