Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
[mlir][python] add MemRefTypeAttr attr builder (#76371)
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental authored Jan 6, 2024
1 parent 6e1ecd1 commit 83be8a7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mlir/python/mlir/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ def _typeArrayAttr(x, context):
return _arrayAttr([TypeAttr.get(t, context=context) for t in x], context)


@register_attribute_builder("MemRefTypeAttr")
def _memref_type_attr(x, context):
return _typeAttr(x, context)


try:
import numpy as np

Expand Down
12 changes: 12 additions & 0 deletions mlir/test/python/dialects/memref.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from mlir.ir import *
import mlir.dialects.func as func
import mlir.dialects.memref as memref
import mlir.extras.types as T


def run(f):
Expand Down Expand Up @@ -76,3 +77,14 @@ def testCustomBuidlers():
# CHECK: memref.load %[[ARG0]][%[[ARG1]], %[[ARG2]]]
print(module)
assert module.operation.verify()


# CHECK-LABEL: TEST: testMemRefAttr
@run
def testMemRefAttr():
with Context() as ctx, Location.unknown(ctx):
module = Module.create()
with InsertionPoint(module.body):
memref.global_("objFifo_in0", T.memref(16, T.i32()))
# CHECK: memref.global @objFifo_in0 : memref<16xi32>
print(module)

0 comments on commit 83be8a7

Please sign in to comment.