File tree 3 files changed +12
-6
lines changed
include/mlir/Bindings/Python
test/python/integration/dialects
3 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -206,7 +206,7 @@ struct type_caster<MlirFrozenRewritePatternSet> {
206
206
bool load (handle src, bool ) {
207
207
py::object capsule = mlirApiObjectToCapsule (src);
208
208
value = mlirPythonCapsuleToFrozenRewritePatternSet (capsule.ptr ());
209
- return ! mlirModuleIsNull ( value) ;
209
+ return value. ptr != nullptr ;
210
210
}
211
211
static handle cast (MlirFrozenRewritePatternSet v, return_value_policy,
212
212
handle) {
Original file line number Diff line number Diff line change 6
6
from ._pdl_ops_gen import _Dialect
7
7
from .._mlir_libs ._mlirDialectsPDL import *
8
8
from .._mlir_libs ._mlirDialectsPDL import OperationType
9
-
9
+ from .. extras . meta import region_op
10
10
11
11
try :
12
12
from ..ir import *
@@ -127,6 +127,9 @@ def body(self):
127
127
return self .regions [0 ].blocks [0 ]
128
128
129
129
130
+ pattern = region_op (PatternOp .__base__ )
131
+
132
+
130
133
@_ods_cext .register_operation (_Dialect , replace = True )
131
134
class ReplaceOp (ReplaceOp ):
132
135
"""Specialization for PDL replace op class."""
@@ -195,6 +198,9 @@ def body(self):
195
198
return self .regions [0 ].blocks [0 ]
196
199
197
200
201
+ rewrite = region_op (RewriteOp )
202
+
203
+
198
204
@_ods_cext .register_operation (_Dialect , replace = True )
199
205
class TypeOp (TypeOp ):
200
206
"""Specialization for PDL type op class."""
Original file line number Diff line number Diff line change @@ -38,8 +38,8 @@ def add_func(a, b):
38
38
m = Module .create ()
39
39
with InsertionPoint (m .body ):
40
40
# Change all arith.addi with index types to arith.muli.
41
- pattern = pdl .PatternOp ( 1 , "addi_to_mul" )
42
- with InsertionPoint ( pattern . body ):
41
+ @ pdl .pattern ( benefit = 1 , sym_name = "addi_to_mul" )
42
+ def pat ( ):
43
43
# Match arith.addi with index types.
44
44
index_type = pdl .TypeOp (IndexType .get ())
45
45
operand0 = pdl .OperandOp (index_type )
@@ -49,8 +49,8 @@ def add_func(a, b):
49
49
)
50
50
51
51
# Replace the matched op with arith.muli.
52
- rewrite = pdl .RewriteOp ( op0 )
53
- with InsertionPoint ( rewrite . add_body () ):
52
+ @ pdl .rewrite ( )
53
+ def rew ( ):
54
54
newOp = pdl .OperationOp (
55
55
name = "arith.muli" , args = [operand0 , operand1 ], types = [index_type ]
56
56
)
You can’t perform that action at this time.
0 commit comments