Files
clang-p2996/mlir/test/python/ir/value.py
Stella Laurenzo 9f3f6d7bd8 Move MLIR python sources to mlir/python.
* NFC but has some fixes for CMake glitches discovered along the way (things not cleaning properly, co-mingled depends).
* Includes previously unsubmitted fix in D98681 and a TODO to fix it more appropriately in a smaller followup.

Differential Revision: https://reviews.llvm.org/D101493
2021-05-03 18:36:48 +00:00

41 lines
947 B
Python

# RUN: %PYTHON %s | FileCheck %s
import gc
from mlir.ir import *
def run(f):
print("\nTEST:", f.__name__)
f()
gc.collect()
assert Context._get_live_count() == 0
# CHECK-LABEL: TEST: testCapsuleConversions
def testCapsuleConversions():
ctx = Context()
ctx.allow_unregistered_dialects = True
with Location.unknown(ctx):
i32 = IntegerType.get_signless(32)
value = Operation.create("custom.op1", results=[i32]).result
value_capsule = value._CAPIPtr
assert '"mlir.ir.Value._CAPIPtr"' in repr(value_capsule)
value2 = Value._CAPICreate(value_capsule)
assert value2 == value
run(testCapsuleConversions)
# CHECK-LABEL: TEST: testOpResultOwner
def testOpResultOwner():
ctx = Context()
ctx.allow_unregistered_dialects = True
with Location.unknown(ctx):
i32 = IntegerType.get_signless(32)
op = Operation.create("custom.op1", results=[i32])
assert op.result.owner == op
run(testOpResultOwner)