File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -197,7 +197,12 @@ class PyRewritePatternSet {
197197 MlirPatternRewriter rewriter,
198198 void *userData) -> MlirLogicalResult {
199199 nb::handle f (static_cast <PyObject *>(userData));
200- nb::object res = f (op, PyPatternRewriter (rewriter));
200+
201+ PyMlirContextRef ctx =
202+ PyMlirContext::forContext (mlirOperationGetContext (op));
203+ nb::object opView = PyOperation::forOperation (ctx, op)->createOpView ();
204+
205+ nb::object res = f (opView, PyPatternRewriter (rewriter));
201206 return logicalResultFromObject (res);
202207 };
203208 MlirRewritePattern pattern = mlirOpRewritePattenCreate (
Original file line number Diff line number Diff line change @@ -17,15 +17,15 @@ def run(f):
1717def testRewritePattern ():
1818 def to_muli (op , rewriter ):
1919 with rewriter .ip :
20- new_op = arith .muli (op .operands [ 0 ] , op .operands [ 1 ] , loc = op .location )
20+ new_op = arith .muli (op .lhs , op .rhs , loc = op .location )
2121 rewriter .replace_op (op , new_op .owner )
2222
2323 def constant_1_to_2 (op , rewriter ):
24- c = op .attributes [ " value" ] .value
24+ c = IntegerAttr ( op .value ) .value
2525 if c != 1 :
2626 return True # failed to match
2727 with rewriter .ip :
28- new_op = arith .constant (op .result . type , 2 , loc = op .location )
28+ new_op = arith .constant (op .type , 2 , loc = op .location )
2929 rewriter .replace_op (op , [new_op ])
3030
3131 with Context ():
You can’t perform that action at this time.
0 commit comments