Skip to content

Commit 83be8a7

Browse files
authored
[mlir][python] add MemRefTypeAttr attr builder (#76371)
1 parent 6e1ecd1 commit 83be8a7

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

mlir/python/mlir/ir.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@ def _typeArrayAttr(x, context):
263263
return _arrayAttr([TypeAttr.get(t, context=context) for t in x], context)
264264

265265

266+
@register_attribute_builder("MemRefTypeAttr")
267+
def _memref_type_attr(x, context):
268+
return _typeAttr(x, context)
269+
270+
266271
try:
267272
import numpy as np
268273

mlir/test/python/dialects/memref.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from mlir.ir import *
44
import mlir.dialects.func as func
55
import mlir.dialects.memref as memref
6+
import mlir.extras.types as T
67

78

89
def run(f):
@@ -76,3 +77,14 @@ def testCustomBuidlers():
7677
# CHECK: memref.load %[[ARG0]][%[[ARG1]], %[[ARG2]]]
7778
print(module)
7879
assert module.operation.verify()
80+
81+
82+
# CHECK-LABEL: TEST: testMemRefAttr
83+
@run
84+
def testMemRefAttr():
85+
with Context() as ctx, Location.unknown(ctx):
86+
module = Module.create()
87+
with InsertionPoint(module.body):
88+
memref.global_("objFifo_in0", T.memref(16, T.i32()))
89+
# CHECK: memref.global @objFifo_in0 : memref<16xi32>
90+
print(module)

0 commit comments

Comments
 (0)